TO_DAY_OF_WEEK
Converts a date or timestamp to a number representing the day of the week (Monday is 1, and Sunday is 7).
Syntax
TO_DAY_OF_WEEK(<date>)
Parameter | Description |
---|---|
<date> | An expression that evaluates to a DATE or TIMESTAMP |
Example
This example below finds the day of week number for April 22, 1975. The string first needs to be transformed to DATE
type using the CAST
function.
SELECT
TO_DAY_OF_WEEK(CAST('1975/04/22' AS DATE)) as res;
Returns: 2