Calculating an end date from business days

Buckmaster

New member
Local time
Today, 02:33
Joined
Apr 29, 2010
Messages
6
I have a form (frmTransferInAging) where the user inputs a value for business days (eg 10) into txtBusDays. The value is used by a query to determine 10 business days from today - For example, if 10 was entered today I want to calculate 10 business days before today - how do I calculate this date?

I am currently using the following criteria in the query which returns calendar days:
<=(Date()-([Forms]![frmTransferInAging]![txtBusDays]))

I believe I can create a function to call from the query?
 
there is no other way than to make a function. if you consider holidays as NON business days you will have to expand the function, but this will work for the simple 5 day work week:
PHP:
<=(Date()-(GetDays([Forms]![frmTransferInAging]![txtBusDays])))

here the function that u need
PHP:
function GetDays(CalDays as double) as double

GetDays = 0

do until CalDays = 0

   if weekday(dateadd(date(), "d", -(CalDays))) <> 1 AND
     weekday(dateadd(date(), "d", -(CalDays))) <> 7 THEN

        GetDays = GetDays + 1

   end if

       CalDays = CalDays - 1

loop

end function

the syntax is pseudo. good luck with it
 

Users who are viewing this thread

Back
Top Bottom