TRUNC (interval)
Purpose
TRUNC(interval)
returns the interval rounded down to the unit specified by the second argument fmt
, the format model .
The absolute value of TRUNC(interval)
is never greater than the absolute value of interval
. The result precision is the same as the input precision, since there is no overflow issue for TRUNC(interval)
.
For INTERVAL YEAR TO MONTH
, fmt
can only be year. The default fmt
is year.
For INTERVAL DAY TO SECOND
, fmt
can be day, hour and minute. The default fmt
is day. Note that fmt
does not support second.
See Also:
Refer to CEIL, FLOOR, ROUND, and TRUNC Date Functions for the permitted format models to use in fmt
.
Examples
SELECT TRUNC(INTERVAL '+123-06' YEAR(3) TO MONTH) AS year_trunc; YEAR_TRUNC ---------- +123-00
SELECT TRUNC(INTERVAL '+99-11' YEAR(2) TO MONTH, 'YEAR') AS year_trunc; YEAR_TRUNC ---------- +99-00
SELECT TRUNC(INTERVAL '+4 12:42:10.222' DAY(2) TO SECOND(3), 'DD') AS day_trunc; DAY_TRUNC ------------------- +04 00:00:00.000000