DayOfWeek and
WeekDay are equivalent functions.
Description
DayOfWeek determines the day of the week the given date falls on, and converts the day of the week to a Number (1 to 7).
Overloads
DayOfWeek (date, firstDayOfWeek)
Arguments
date is a Date value or dateTime value.
Action
DayOfWeek determines the day of the week the given date falls on, and converts the day of the week to a Number (1 to 7). Optionally a numeric value for the first day of the week can be specified. If the first day of the week is not specified, Sunday is assumed.
Typical uses
Use this function any time you need to use the day of the week as a Number.
Examples
DayOfWeek(Date(1990,10,1))
Returns 2 where October 1, 1990 is a Monday.
If DayOfWeek({orders.ORDER DATE}) = 3 Then
"Sam"
Else
"Bill"
Determines whether Sam or Bill was on duty on September 8, 1990.
If DayOfWeek({orders.ORDER DATE}) = 7 Then
"Saturday"
Else
""
Returns "Saturday" if the DayOfWeek is 7; otherwise, it returns an empty string.
DayOfWeek(#Sept. 24, 1999#, crMonday)
Returns 5 where Sept. 24, 1999, is a Friday, and Monday is specified to be the first day of the week.
Comments
If you want to get the day of the week spelled out, in Crystal syntax, use this formula:
["Sun", "Mon", "Tues",...] [DayOfWeek(Date)]
Sets up an array (["Sun",...]) and uses the number of the day of the week (Sun = 1, Sat = 7) to select the desired date name from the array.