INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• 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.

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'

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

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

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:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!