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!

Count of days excluding weekends

Status
Not open for further replies.

jvolden

IS-IT--Management
Jan 26, 2005
77
US
I want to count the number of days between two dates excluding saturday and sundays. So if the strt date was thursday the 16th and the end date monday the 20th the count of days would be 2 not 4.
Thank you.
I am using Crystal Reports 11.
 
There are quite a few posts in the Business Objects:Crystal Reports1 Formulas group on this. But this should work:
Code:
local datevar startdate;
local datevar enddate;
numbervar bdays;

startdate:= {MyTable.StartDate};

enddate:= {MyTable.EndDateOrderDate};

 
bdays:= 
(
DateDiff ("d", fd, ld) - 
    DateDiff ("ww", fd, ld, crSaturday) - 
    DateDiff ("ww", fd, ld, crSunday)
)  
;

if DayOfWeek (startdate) in [1,7] then bdays := bdays -1;

bdays

[code]

Do consider public holidays though and for this I have seen a formula on Ken Hamady's website [URL unfurl="true"]www.kenhamady.com/formula.html[/URL]

ShortyA

ShortyA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top