Steven:
Given that business days are generally monday thru friday, you can use the
code below (where date, daysUntilDue & dueDate would be values from your
database).
<cfset date = now()>
<cfset daysUntilDue = 5>
<cfset dueDate = dateAdd("d", daysUntilDue, date)>
<cfset businessDays = "2,3,4,5,6">
<cfset businessDaysUntilDue = 0>
<cfloop from="#date#" to="#dueDate#" index="i">
<cfif ListFind(businessDays,dayOfWeek(i))>
<cfset businessDaysUntilDue = businessDaysUntilDue + 1>
</cfif>
</cfloop>
<cfoutput>businessDaysUntilDue: #businessDaysUntilDue#</cfoutput>
NOTE that this does not cover holidays (such as the US holidays: President's
Day, Thanksgiving, etc.) To work with this, you could modify the logic as
follows:
<!--- Easter, The Fourth of July, Christmas - Day of the Year --->
<cfset holidays = "90,185,359">
<cfloop from="#date#" to="#dueDate#" index="i">
<cfif ListFind(businessDays,dayOfWeek(i))>
<cfif NOT ListFind(holidays,dayOfYear(i))>
<cfset businessDaysUntilDue = businessDaysUntilDue + 1>
</cfif>
</cfif>
</cfloop>
Hope this helps!
----- Original Message -----
From: "LANCASTER, STEVEN M. (JSC-OL) (BAR)"
<[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Saturday, March 23, 2002 1:56 PM
Subject: Business days from Dates PLEASE HELP!!!!
> I have a Database it has a date in one of the columns. I take that date
and
> another column in the table which is just an integer an use the DateAdd
> function to come up with a second date.
>
> I have:
>
> date1, duedate(created from the DateAdd function), days_until_it_is_due
>
> Now I need to give these people X amount of business days based on
> days_until_it_is_due to come up with a proper due date. Can anyone please
> help me or tell me where to start..
>
> Steven Lancaster
>
______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists