Returns the specified part of a date as an integer value. For example, if you create an expression that returns the month portion of the date, and pass a date such as Apr 1 1997 00:00:00, GET_DATE_PART returns 4.
Syntax
GET_DATE_PART( date, format )
Argument
Required/
Optional
Description
date
Required
Date/Time datatype. You can enter any valid expression.
format
Required
A format string specifying the portion of the date value you want to change. Enclose format strings within single quotation marks, for example, 'mm'. The format string is not case sensitive. Each format string returns the entire part of the date based on the default format of MM/DD/YYYY HH24:MI:SS.
For example, if you pass the date Apr 1 1997 to GET_DATE_PART, the format strings 'Y', 'YY', 'YYY', or 'YYYY' all return 1997.
Return Value
Integer representing the specified part of the date.
NULL if a value passed to the function is NULL.
Example
The following expressions return the hour for each date in the DATE_SHIPPED column. 12:00:00AM returns 0 because the default date format is based on the 24 hour interval: