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!

Busines Days in R5

Status
Not open for further replies.

jtellezl

IS-IT--Management
Jun 4, 2004
3
US
I need to calculate how many business days are in a range of dates, this is for R5, any ideas ?
 
This code will do it for you. The two date fields here are dtStartDate and dtEndDate.

Code:
StartingSaturDay:=@If(
@Weekday(dtStartDate) < 7; @Adjust(dtStartDate;0;0;(7-@Weekday(dtStartDate));0;0;0);
dtStartDate);

StartingSunday:=@If(
@Weekday(dtStartDate) > 1;@Adjust(dtStartDate;0;0;(8-@Weekday(dtStartDate));0;0;0);
dtStartDate);

EndingSaturDay:=@If(
@Weekday(dtEndDate) < 7;@Adjust(dtEndDate;0;0;-(@Weekday(dtEndDate));0;0;0);
dtEndDate);

EndingSunday:=@If(
@Weekday(dtEndDate) > 1;@Adjust(dtEndDate;0;0;-(@Weekday(dtEndDate) - 1);0;0;0);
dtEndDate);

TotCount:=((((EndingSaturDay - StartingSaturDay)/86400)/7) + 1) +
((((EndingSunday - StartingSunday)/86400)/7) + 1);

TotalDays := (dtEndDate - dtStartDate) /86400 + 1;

Weekday := TotalDays - TotCount;

Weekday

Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top