DAYOFWEEK (date)

Returns an integer of the day of week. 1..7.

See also: DAY, FORMAT.

Example:

/* Retrieve list of weekdays with weekday name. */ 
/* Be aware that the day name may be differ based on culture of the machine you’re running this script on. */
/* E.g. Sunday may be day #1 */
SELECT DISTINCT thedate,DAYOFWEEK(thedate) WeekDayNo,
CASE DAYOFWEEK(thedate)
WHEN 1 THEN 'Monday'
WHEN 2 THEN 'Tuesday'
WHEN 3 THEN 'Wednesday'
WHEN 4 THEN 'Thursday'
WHEN 5 THEN 'Friday'
WHEN 6 THEN 'Saturday'
WHEN 7 THEN 'Sunday'
ELSE
'none'
END AS WeekDayName
FROM transact
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.