OQL DATEPART

Last modified: August 27, 2024

Description

The DATEPART function retrieves a specified element from a date/time values. This element is of type integer.

Syntax

The syntax is as follows:

DATEPART ( datepart , date_expression [, timezone ] )

datepart

datepart specifies the part of the date/time value to retrieve. For possible values, see the Example below.

date_expression

date_expression specifies the date to retrieve an element from. This should be formatted in an expression which resolves to a date/time value.

timezone

timezone specifies the time zone to use for the retrieval. This parameter is optional and defaults to the local time zone. It should be a string literal containing an IANA time zone. GMT offset time zones are not supported.

Example

datepartDefinitionExample (Friday July 1, 2005, 16:34:20)
YEAR2005
QUARTER1, 2, 3 or 43
MONTH1 to 127
DAYOFYEAR1 to 366
DAY1 to 315
WEEK1 to 53 (depends on the database implementation)
WEEKDAY1 to 7 (1 = Sunday, 7 = Saturday)6
HOUR0 to 2316
MINUTE0 to 5934
SECOND0 to 5920