There is a business days calculator on the cflib.org website as a UDF.

--Dharmesh

-----Original Message-----
From: Scott Van Vliet [mailto:[EMAIL PROTECTED]]
Sent: Sunday, March 24, 2002 1:53 AM
To: CF-Talk
Subject: Re: Business days from Dates PLEASE HELP!!!!


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
> 

______________________________________________________________________
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.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

Reply via email to