Date_Trunc Function; Examples Of Date_Trunc - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

DATE_TRUNC Function

The DATE_TRUNC function returns a value of type TIMESTAMP, which has all fields of lesser
precision than text set to zero (or 1 in the case of months or days).
DATE_TRUNC is a Neoview extension.
DATE_TRUNC(text, datetime_expr)
text
specifies 'YEAR', 'MONTH', 'DAY', 'HOUR', 'MINUTE', or 'SECOND'. The DATE_TRUNC
function also accepts the specification of 'CENTURY' or 'DECADE'.
datetime_expr
is an expression that evaluates to a datetime value of type DATE or TIMESTAMP.
DATE_TRUNC returns a value of type TIMESTAMP which has all fields of lesser precision
than text set to zero (or 1 in the case of months or days). See
(page
257).

Examples of DATE_TRUNC

This function returns the value of TIMESTAMP '2006-12-31 00:00:00'.
DATE_TRUNC('DAY', TIMESTAMP '2006-12-31 11:59:59')
This function returns the value of TIMESTAMP '2006-01-01 00:00:00'
DATE_TRUNC('YEAR', TIMESTAMP '2006-12-31 11:59:59')
This function returns the value of TIMESTAMP '2006-12-01 00:00:00'
DATE_TRUNC('MONTH', DATE '2006-12-31')
Restrictions:
— DATE_TRUNC( 'DECADE', ...) cannot be used on years less than 10.
— DATE_TRUNC( 'CENTURY', ...) cannot be used on years less than 100.
386
SQL Functions and Expressions
"Datetime Value Expressions"

Advertisement

Table of Contents
loading

Table of Contents