Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Business Objects: Crystal Reports 1 Formulas FAQ

Formula Help

Count the number of individual days in a date range by GJParker
Posted: 14 Dec 05 (Edited 16 Dec 05)

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'


//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
    CountDays [DayOfWeek (CheckDate, CrMonday )] := CountDays [DayOfWeek (CheckDate, CrMonday )] + 1;
    CheckDate := CheckDate + 1

//Build the display string
For i := 1 to 7
    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

Back to Business Objects: Crystal Reports 1 Formulas FAQ Index
Back to Business Objects: Crystal Reports 1 Formulas Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close