Date_Part Function (Of A Timestamp); Examples Of Date_Part - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

DATE_PART Function (of a Timestamp)

The DATE_PART function extracts the datetime field specified by text from the datetime value
specified by datetime_expr 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.
The DATE_PART function of a timestamp can be changed to DATE_PART function of a datetime
because the second argument can be either a timestamp or a date expression.
DATE_PART is a Neoview extension.
DATE_PART(text, datetime_expr)
text
specifies YEAR, MONTH, DAY, HOUR, MINUTE, or SECOND. The value must be enclosed
in single quotes.
datetime_expr
is an expression that evaluates to a datetime value of type DATE or TIMESTAMP. See
"Datetime Value Expressions" (page
DATE_PART(text, datetime_expr) is equivalent to EXTRACT(text, datetime_expr), except
that DATE_PART requires single quotes around the text specification where EXTRACT does not
allow single quotes.

Examples of DATE_PART

This function returns the value of 12.
DATE_PART('month', date'12/05/2006')
This function returns the value of 2006.
DATE_PART('year', date'12/05/2006')
This function returns the value of 31.
DATE_PART('day', TIMESTAMP '2006-12-31 11:59:59.999999')
257).
DATE_PART Function (of a Timestamp)
385

Advertisement

Table of Contents
loading

Table of Contents