dayofweek

Return the day of the week

Syntax

dayofweek(dt_expr)

Arguments

dt_expr A date expression.

Description

This function returns the day of the week in the specified date expression as a number between 1 and 7, where 1 is Sunday.

The data type DATE assumes the Gregorian calendar even for dates prior to the introduction of the Gregorian calendar. This means that databases that store historical dates prior to the introduction of the Gregorian calendar may not compute SELECT with date ranges, DAYOFWEEK, and WEEK correctly.

Example

select dayofweek("2013-04-17") as "Day of Week";

Day of Week
          4