cancel
Showing results for 
Search instead for 
Did you mean: 

Day of Week Function

Former Member
0 Kudos

Is there a function in Crystal that tells you the day of the week that a date is???

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Yes

Dayofweek(date)   //will give you the number of the day of the week with 1 being Sunday
Weekdayname(Dayofweek(date))   //will give you the name of the day

for other date/time functions, look under functions for date and time in the formula workshop

Answers (1)

Answers (1)

Former Member
0 Kudos

Yes there is... One of which is actually called DayOfWeek. You can also use the DatePart function as well. Both will return an integer value ranging from 1 - 7.


DayOfWeek({TableName.DateField})
-or-
DatePart("w", {TableName.DateField})

If you want to get the actual name of the week you can use a formula like this...


SELECT DayOfWeek(CurrentDate)
CASE 1 : "Sunday"
CASE 2 : "Monday"
CASE 3 : "Tuesday"
CASE 4 : "Wednesday"
CASE 5 : "Thursday"
CASE 6 : "Friday"
CASE 7 : "Saturday"
;

HTH,

Jason

-


Interesting Deb... I've never used WeekDayName.

Edited by: Jason Long on Sep 21, 2010 8:45 AM

Former Member
0 Kudos

Jason, try it, you'll like it. ; )

Former Member
0 Kudos

I'll give it a shot.