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

Count the number of individual days in a date range

Formula Help

Count the number of individual days in a date range

by  GJParker  Posted    (Edited  )
This formula uses an array to store the count of each day between 2 dates.

Place this formula anywhere on the report and set the field format to 'Can Grow'

Code:
//Declare all the required variables
Local NumberVar Array CountDays;
Redim CountDays [7];
Local DateVar CheckDate := {?StartDate};
Local NumberVar i;
Local StringVar Display;

//Loop through the date range and increment the array
While CheckDate <> {?EndDate} + 1
Do
(
    CountDays [DayOfWeek (CheckDate, CrMonday )] := CountDays [DayOfWeek (CheckDate, CrMonday )] + 1;
    CheckDate := CheckDate + 1
);

//Build the display string
For i := 1 to 7 
Do
    Display := Display & WeekdayName (i, False, crMonday) & " = " &  cstr(CountDays[i],0,"") & " day(s)" & chr(13);

//Display the results
"Between " & {?StartDate} & " and " & {?EndDate} & " there are :- " & chr(13) & Display
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top