Function to return the next available business DATE

Hi,

I need to determine how to write a function that will accept the a date as 02/20/2006 and return the next business date available.

I have a db table that stores the holidays, but it needs to take into account the weekends (Sat, Sun) as well.

I want this function to return the next available business "date"

Can someone assist in this?

-ws
LVL 1
Westside2004Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrichmonCommented:
I would look at this file and maybe make modifications:
http://www.experts-exchange.com/Web/WebDevSoftware/ColdFusion/Q_11321437.html

It calcualtes the number of business days between two days.
mrichmonCommented:
The basic idea for your function will be to read in the list of holiday dates

<cfquery name="GetHolidays" datasource="yourdsn">
SELECT holidaydate FROM yourtable
</cfquery>

<!--- Create a list --->
<cfset holidayList = "">
<cfloop query="GetHolidays">
   <cfset holidayList = ListAppend(holidayList, holidaydate)>
</cfloop>

<cfset currentDate = Form.dateEntered>
<cfset businessdayNotFound = true>
<cfloop condition="#businessdayNotFound#">
   <cfset currentDate = DateAdd("d", 1, currentDate)>
   <cfif ListFind(holidayList, currentDate) EQ 0 AND DayOfWeek(currentDate) NEQ 1 AND DayOfWeek(currentDate) NEQ 7>
       <cfset businessdayNotFound = false>
   </cfif>
</cfloop>

The next business day is <cfoutput>#currentDate#</cfoutput>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Westside2004Author Commented:
Hi,

Thanks, this almost works, except it does not filter out the holidays coming from the query.

I entered 2/10/2006, lincoln b-day is 2/13/2006, so next biz day is 2/14/2006, but it returns 2/13/2006

Almost there.

any idea why?

-ws
Westside2004Author Commented:
fixed it... no worries thx
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.