WEEK
Returns the week of the year for the specified date as an integer, where the first week begins on the first Sunday on or preceding January 1.
Syntax
WEEK ( date )
Behavior Type
- Immutable if the
specified date is a
TIMESTAMP
,DATE
, orVARCHAR
- Stable if the specified date is a
TIMESTAMPTZ
Parameters
date |
The date to process, one of the following data types: |
Examples
January 2 is on Saturday, so WEEK
returns 1:
=> SELECT WEEK ('1-2-2016'::DATE); WEEK ------ 1 (1 row)
January 3 is the second Sunday in 2016, so WEEK
returns 2:
=> SELECT WEEK ('1-3-2016'::DATE); WEEK ------ 2 (1 row)