This Oracle tutorial explains how to use the Oracle/PLSQL TRUNC function (as it applies to date values) with syntax and examples.
The Oracle/PLSQL TRUNC function returns a date truncated to a specific unit of measure.
The syntax for the TRUNC function in Oracle/PLSQL is:
The date to truncate.
Optional. The unit of measure to apply for truncating. If the format parameter is omitted, the TRUNC function will truncate the date to the day value, so that any hours, minutes, or seconds will be truncated off. It can be one of the following values:
Unit | Valid format parameters |
---|---|
Year | SYYYY, YYYY, YEAR, SYEAR, YYY, YY, Y |
ISO Year | IYYY, IY, I |
Quarter | Q |
Month | MONTH, MON, MM, RM |
Week | WW |
IW | IW |
W | W |
Day | DDD, DD, J |
Start day of the week | DAY, DY, D |
Hour | HH, HH12, HH24 |
Minute | MI |
The TRUNC function (as it applies to dates) returns a date value.
The TRUNC function can be used in the following versions of Oracle/PLSQL:
Let's look at some Oracle TRUNC function examples and explore how to use the TRUNC function in Oracle/PLSQL.
For example: