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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formual to calculate number of days

Status
Not open for further replies.

Djbell

IS-IT--Management
Apr 22, 2002
175
GB
Hi All

Can anyone help me with a formula that calculates the number of days between 2 dates. This formula must include both the startdate and enddate in its count, it must also exclude Friday,Sat,Sun.

I then need a fomula that calculates the number of Fridays in a given date range, again like above.

Hope you can help

Regards

Douglas Bell
 
Try this formula

Code:
WhileReadingRecords;
Local DateVar Start := {?StartDate};   // place your Starting Date here
Local DateVar End := {?EndDate};  // place your Ending Date here
Local Datevar TestDay;
Local NumberVar i; 
Local NumberVar Days;

Do (
TestDay := Start + i;
i := i + 1;
If DayofWeek(TestDay) in [2,3,4,5] Then Days := Days + 1;
)
while TestDay <> End;
  
Days

and this one for the Fridays

Code:
WhileReadingRecords;
Local DateVar Start := {?StartDate};   // place your Starting Date here
Local DateVar End := {?EndDate};  // place your Ending Date here
Local Datevar TestDay;
Local NumberVar i; 
Local NumberVar Fridays;

Do (
TestDay := Start + i;
i := i + 1;
If DayofWeek(TestDay) = 6 Then FriDays := Fridays + 1;
)
while TestDay <> End;
  
Fridays

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top