TO_WEEK
Converts a date or timestamp to a number representing the week. This function defines week 1 of a calendar year as the first full week of a calendar year starting on a Sunday.
Syntax
TO_WEEK(<date>)
Parameter | Description |
---|---|
<date> | The date or timestamp to be converted into the number of the week. |
Example
For Sunday, Jan. 1, 2017:
SELECT
TO_WEEK(CAST('2017/01/01' AS DATE))
Returns: 1
For Monday, Jan. 1, 2018:
SELECT
TO_WEEK(CAST('2018/01/01' AS DATE))
Returns: 0