Calculating Business Hours
ColdFusion function
Categories: ColdFusion code snippets
I've had several requests for a copy of a function i wrote that calculates business time between two datetimes, so figured I'd go ahead and make it available via my blog.
It's kind of a long function, but I built it to be thorough and do a lot of validation and such. Also, there are several supporting function included as well that it uses (not all of which are mine...credit given where applicable).
I couldn't find any documentation ( I thought I had written some, but it was probably just an email I sent to my coworkers), but it's fairly straightforward. Here's a sample call:
<cfset thesebizmins=bizMins(begin_dt,end_dt,8,17,12,"n")>
the function is heavily commented, including a header that explains the parameters and such. Let me know if you have any questions on it and I'll try to answer them.
You may need to edit the function getCompanyHolidays(). It has all the normal ones already, but there may be some you want to add or omit.
If you get any errors because a function is missing, let me know; I may have missed one of the supporting functions.
Oh, and feel absolutely free to share this with anybody you like. I am a true believer in the spirit of the internet, that nobody else should have to go through the same pains I have if me sharing what I learned
can prevent it.
Pay it forward.... :0)
Doug :0)
P.S. Oops! I had forgotten to include the supporting function 'validHour' (thanks Cathy Martin!), so added that just now (2/27/07).
************** Download the Code Here ********************
It's kind of a long function, but I built it to be thorough and do a lot of validation and such. Also, there are several supporting function included as well that it uses (not all of which are mine...credit given where applicable).
I couldn't find any documentation ( I thought I had written some, but it was probably just an email I sent to my coworkers), but it's fairly straightforward. Here's a sample call:
<cfset thesebizmins=bizMins(begin_dt,end_dt,8,17,12,"n")>
the function is heavily commented, including a header that explains the parameters and such. Let me know if you have any questions on it and I'll try to answer them.
You may need to edit the function getCompanyHolidays(). It has all the normal ones already, but there may be some you want to add or omit.
If you get any errors because a function is missing, let me know; I may have missed one of the supporting functions.
Oh, and feel absolutely free to share this with anybody you like. I am a true believer in the spirit of the internet, that nobody else should have to go through the same pains I have if me sharing what I learned
can prevent it.
Pay it forward.... :0)
Doug :0)
P.S. Oops! I had forgotten to include the supporting function 'validHour' (thanks Cathy Martin!), so added that just now (2/27/07).
************** Download the Code Here ********************
Subscription Options
You are not logged in, so your subscription status for this entry is unknown. You can login or register here.
Re: Calculating Business Hours
Thanks for the code. It'd worked great and very detailed too.
Posted by Jim Pickering on June 16, 2006 at 5:28 PM