Symptom
How to find the date of the first day of the week from Crystal Reports?
Environment
- Crystal Reports 2008
- SAP Crystal Reports 2011
Resolution
Create a Crystal Report having a formula with the following code:
datevar x := {datefield}; // datefield represent the field from the database
If DayOfWeek(x) = 1 Then
x
Else If DayOfWeek(x) = 2 Then dateadd ("d",-1,x)
Else If DayOfWeek(x) = 3 Then dateadd ("d",-2,x)
Else If DayOfWeek(x) = 4 Then dateadd ("d",-3,x)
Else If DayOfWeek(x) = 5 Then dateadd ("d",-4,x)
Else If DayOfWeek(x) = 6 Then dateadd ("d",-5,x)
Else If DayOfWeek(x) = 7 Then dateadd ("d",-6,x)
Keywords
Crystal reports, Date, Week, First, Day , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , Problem