Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Number of work days between 2 dates

Status
Not open for further replies.

gscheepers

IS-IT--Management
Jan 21, 2002
150
US
Hi everyone,

I'm trying to work out the number of work days between two dates.

I've been trying to use this formula, but it's not giving me the exact result I'm looking for:

datevar firstday;datevar lastday;numbervar loop;numbervar wds; numbervar span;
firstday:=date({ABSENCE.First_day});
lastday:=date({ABSENCE.Last_day});

span:=lastday-firstday;
For loop:= 0 to span do(
if dayofweek(firstday+loop)in [2 to 7] then wds:=wds+1 else wds:=wds);
//holidays
if Date(2002,01,01) in firstday to lastday then wds:= wds-1 ;
wds

The two dates appears in the details section.

Your help would be greatly appreciated! Gerhard Scheepers

"Great souls have wills; feeble ones only wishes..."
 
There are several formulas that do this already. One is in faq149-243. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top