Instead of this: <!--- IF Sunday, Ship Tuesday---> <cfif #DayOfWeek(TodaysDate)# EQ 1> <cfset NewDay = #DateAdd("d", 2, TodaysDate)#> <!--- IF Monday, Ship Wed---> <cfelseif #DayOfWeek(TodaysDate)# EQ 2 > <cfset NewDay = #DateAdd("d", 2, TodaysDate)#> <!--- IF Tuesday, Ship Thurs---> <cfelseif #DayOfWeek(TodaysDate)# EQ 3 > <cfset NewDay = #DateAdd("d", 2, TodaysDate)#> <!--- IF Wednesday, Ship Fri---> <cfelseif #DayOfWeek(TodaysDate)# EQ 4 > <cfset NewDay = #DateAdd("d", 2, TodaysDate)#> <!--- IF Thursday, Ship Monday---> <cfelseif #DayOfWeek(TodaysDate)# EQ 5 > <cfset NewDay = #DateAdd("d", 4, TodaysDate)#> <!--- IF Friday, Ship Tues---> <cfelseif #DayOfWeek(TodaysDate)# EQ 6 > <cfset NewDay = #DateAdd("d", 4, TodaysDate)#> <!--- IF Saturday, Ship Tues---> <cfelseif #DayOfWeek(TodaysDate)# EQ 7 > <cfset NewDay = #DateAdd("d", 3, TodaysDate)#> </cfif>
How about this (assuming CF8 or higher): <cfset shipDays = [2,2,2,2,4,4,3]> <cfset NewDay = DateAdd("d", shipDays[DayOfWeek(TodaysDate)] , TodaysDate)> It's a lot less decisions and probably easier to read and maintain. mxAjax / CFAjax docs and other useful articles: http://www.bifrost.com.au/blog/ 2010/1/16 Eric Nicholas Sweeney <n...@bigfatdesigns.com>: > > You are absolutely right Qing - a little sloppy of me in the coding. Fixed > now. Thanks! > > As for the UDF - I am not sure that works - as I need Saturday as an > option... > > Are there any thoughts on the cfifs and loops? Is that the "best" way to > handle this? I may have to run this as a UDF several times on a page - and > I Was just wondering about performance. > > I am trying to learn how to make things go "faster" - or more streamlined... > And this seems like the perfect case - but I don't know what else to do... > > - Nick > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:329725 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4