0% found this document useful (0 votes)
137 views

TRUNC Function (With Dates)

The TRUNC function in Oracle/PLSQL returns a date truncated to a specified unit of measure. The function syntax includes the date to truncate and an optional format parameter for the unit. If no format is specified, the date is truncated to the day. Valid format parameters include year, quarter, month, week, day, hour, and minute. The TRUNC function can truncate dates in Oracle from version 8i to the current release.

Uploaded by

1raju1234
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views

TRUNC Function (With Dates)

The TRUNC function in Oracle/PLSQL returns a date truncated to a specified unit of measure. The function syntax includes the date to truncate and an optional format parameter for the unit. If no format is specified, the date is truncated to the day. Valid format parameters include year, quarter, month, week, day, hour, and minute. The TRUNC function can truncate dates in Oracle from version 8i to the current release.

Uploaded by

1raju1234
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Oracle/PLSQL: TRUNC Function (with dates)

In Oracle/PLSQL, the TRUNC function returns a date truncated to a specific unit of measure.

Syntax
The syntax for the TRUNC function is: TRUNC ( date, [ format ] ) date is the date to truncate. format is 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. Below are the valid format parameters: Unit Year ISO Year Quarter Month Week IW W Day Valid format parameters SYYYY, YYYY, YEAR, SYEAR, YYY, YY, Y IYYY, IY, I Q MONTH, MON, MM, RM WW IW W DDD, DD, J

Start day of the week DAY, DY, D Hour Minute HH, HH12, HH24 MI

Applies To

Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i

For Example
The TRUNC function can be used in Oracle/PLSQL. For example: TRUNC(TO_DATE('22-AUG-03'), 'YEAR') TRUNC(TO_DATE('22-AUG-03'), 'Q') TRUNC(TO_DATE('22-AUG-03'), 'MONTH') TRUNC(TO_DATE('22-AUG-03'), 'DDD') TRUNC(TO_DATE('22-AUG-03'), 'DAY') would return '01-JAN-03' would return '01-JUL-03' would return '01-AUG-03' would return '22-AUG-03' would return '17-AUG-03'

You might also like