Tuesday, July 29, 2008

Crystal Report - Group Weekly

In Crystal Report, when you group Date or DateTime data types by weekly, first day of the week will be Sunday by default.

You can set the first day of the week to Monday, Saturday, ... etc.

Create a formula e.g. WeeklyMonday, and insert the following formula:-
Datevalue(RecordsDateTimeColumn) - WeekDay (RecordsDateTimeColumn, crMonday) + 1
Then Create Group Weekly by using the formula that we created: WeeklyMonday and select "by Daily" at the "Group Option".

*Remember to replace the [RecordsDateTimeColumn] with your database field

WeekDayName(WeekDay(RecordsDateTimeColumn), True, CrSunday) will return Mon, Tue, Wed .. Sun
WeekDay will output the number that represent Sun, Mon, ... Sat start with 1.00, 2.00, ... 7.00 by default.

2 comments:

Al Dimond said...

Meeeeeeooooooooooow!

Ing said...

When a cat "Meeeeeeooooooooooow!", it means like it. Thanks for your comment.