Check out this UDF: http://www.cflib.org/udf/BusinessDaysAdd

<http://www.cflib.org/udf/BusinessDaysAdd>Also, if I may venture to suggest:

   1. You don't need sharp signs inside ColdFusion tags
   2. It would be nice to use cfqueryparam to pass in those variables to
   your query--faster and more secure.

Happy Friday! [?]

On Fri, Jan 15, 2010 at 5:21 PM, Nick Sweeney <[email protected]>wrote:

>
> Hey everyone - I was wondering if anyone could suggest a "better" method of
> doing this.
>
> Essentially I am creating a dropdown list of Shipping Prices - based on the
> day they are making the purchase. (Customer defined "Next Day Shipping"
> prices - not UPS)
>
> It's Working - but I wonder if there is a more efficient way of doing the
> same thing... Not so many loops or cfif's...
>
> Thoughts? Ideas?  Thanks! - Nick
>
> Live Example here: http://cf.bigfatdesigns.com/cart/ShipCostTest.cfm
>
> Code:
> <!---Set The Item Price FOR DEMO--->
> <cfset ThisItemPrice = "39.99">
>
> <!--- Setup Dates For Price Structure --->
> <cfset TodaysDate = "1/15/2010">
>
>
> <!--- Get Shipping Fees based on Cost --->
> <cfquery name="qryGetShipCosts" datasource="#Application.DSN#"
> username="#Application.username#" password="#Application.password#">
> SELECT SCostID, MinItemPrice, MaxItemPrice, Standard, TwoDay, NextDay,
> Saturday
> FROM ShipCostChart
> WHERE MinItemPrice < #ThisItemPrice#
> AND MaxItemPrice > #ThisItemPrice#
> </cfquery>
>
> <!---
> Determine the FIRST possible day we can ship on
> Based on What Day Of The Week TODAY is
> *Set as first day of dropdown for Next Day Shipping*
> --->
> <!--- 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>
>
> <h1>START > TODAY > #DayOfWeekAsString(DayOfWeek(TodaysDate))#   #NewDay#
> </h1>
> <p><em>LIST will actually be a SELECT Drop Down</em></p>
> <ul>
> <cfloop from="1" to="30" index="i">
>                <cfif #DayOfWeek(NewDay)#  NEQ 1>
>
>            <li>#LSDateFormat(NewDay, 'mmm-dd-yyyy')# -
> #DayOfWeekAsString(DayOfWeek(NewDay))#
>
>                <cfloop query="qryGetShipCosts">
>                <!---Next Day Delivery --->
>                    <cfif i EQ 1>
>                        <strong>#qryGetShipCosts.NextDay#</strong>
>                <!---Two Day Delivery --->
>                    <cfelseif i EQ 2>
>                        <strong>#qryGetShipCosts.TwoDay#</strong>
>                    <cfelse>
>                        <cfif #DayOfWeek(NewDay)#  NEQ 7>
>                                    #qryGetShipCosts.Standard#
>                        <cfelse>
>                                #qryGetShipCosts.Saturday#
>                        </cfif>
>                    </cfif>
>                    </cfloop>
>
>            </li>
>
>        </cfif>
>        <cfset NewDay = #DateAdd("d", 1, NewDay)#>
> </cfloop>
> </ul>
>
> </cfoutput>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:329711
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to