Neoview SQL Reference Manual (R2.5)
DATE_PART Function (of an Interval)
The DATE_PART function extracts the datetime field specified by text from the interval
value specified by interval and returns the result as an exact numeric value. The DATE_PART
function accepts the specification of 'YEAR', 'MONTH', 'DAY', 'HOUR', 'MINUTE', or 'SECOND'
for text.
DATE_PART is a Neoview extension.
DATE_PART (text, interval)
text
specifies YEAR, MONTH, DAY, HOUR, MINUTE, or SECOND. The value must be enclosed
in single quotes.
interval
interval accepts all interval expression types that the Neoview database software considers
as valid interval expressions. See “Interval Value Expressions” (page 261).
The DATE_PART(text, interval) is equivalent to EXTRACT(text, interval), except that
the DATE_PART function requires single quotes around the text specification, where EXTRACT
does not allow single quotes.
When SECOND is specified the fractional part of the second is returned.
Examples of DATE_PART
• This function returns the value of 7.
DATE_PART('DAY', INTERVAL '07:04' DAY TO HOUR)
• This function returns the value of 6.
DATE_PART('MONTH', INTERVAL '6' MONTH)
• This function returns the value of 36.33.
DATE_PART('SECOND', INTERVAL '5:2:15:36.33' DAY TO SECOND(2))
384 SQL Functions and Expressions