Returns an integer representing the specified part of a date. Weekdays are numbered as: Monday = 1, Tuesday = 2, ..., Saturday = 6, Sunday = 7. Time zone offsets are represented as a positive or negative number of minutes (for instance, an offset of "-04:00" is represented as -240).
- date-part (text expression)
One of the following predefined strings. Each date-part has abbreviated aliases that can be used in place of the longer names without affecting the behavior.
- date (date/time expression)
A text value that can be parsed into a date/time with time zone offset. If no time zone is specified in the string, then the system's local time zone is assumed.
An integer representing the part of date that is specified by date-part.
PRINT DATEPART('month', '2016-07-23');
PRINT DATEPART('weekday', '2016-07-23');
DECLARE @x = DATEPART('dd', '2016-07-23');
Assigns the integer 23 to
PRINT DATEPART('tzoffset', '2016-07-23 12:00 -04:00');