Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Subtracting dates - can you count only business days
Message
From
08/08/1999 18:56:02
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00250320
Message ID:
00251308
Views:
16
>>>You're right. Would you just put a holidays table with holidays for the next several years?
>>>
>>>Thanks.
>>>Doug
>>
>>That really depends how far out you need. We have one customer that needs holidays out for 5 years.
>
>PMFJI- Here's a couple of sites that list holidays.
>
>http://www.national-holidays.com/
>
>This site says a database of all the holidays in under construction.
>http://www.holidayfestival.com/
>
>HTH

Doug

Once you have the hollidays under control, you still need a basic approach to get the non-holiday days. The following should get you going in the right direction ....

ps Great picture Roi!

Bob
function WeekDays(tuStart, tuEnd)

* 1999 - Bob Cassady - Software Systems

* Returns number of weekdays (Mon to Fri) between two dates, inclusive.
* Accepts either dates, or datetimes, or both as parameters
* Does not account for holidays.

* The time range is made up of 0 or more FULL 7 day weeks (each having
* 5 weekdays), plus from zero to 6 more days (lnExtraDays) of which zero
* or more are weekdays (lnExtraWkDays).

local luTemp, ldStart, ldEnd, lnTotRange, lnExtraDays, lnExtraWkDays

if tuStart > tuEnd    && Put dates in order ... earlier, later
  luTemp  = tuEnd
  tuEnd   = tuStart
  tuStart = luTemp
endif

ldStart    = iif(type("tuStart") = "D", tuStart, ttod(tuStart))
ldEnd      = iif(type("tuEnd")   = "D", tuEnd,   ttod(tuEnd))
lnTotRange = ldEnd - ldStart + 1  

lnExtraDays   = (lnTotRange % 7) - 1
lnExtraWkDays = 0

for i = 0 to lnExtraDays
  lnExtraWkDays = lnExtraWkDays + iif(between(dow(ldStart+i),2,6),1,0)
endfor

return (int(lnTotRange/7) * 5) + lnExtraWkDays
Previous
Reply
Map
View

Click here to load this message in the networking platform