Pattern Description
CC, SCC Returns January 1, cc01 where cc is first 2 digits of the given year
SYYY, YYYY, YEAR, SYEAR, YYY, YY, Y Returns January 1, yyyy where yyyy is the given year
IYYY, IYY, IY, I Returns the start date of the ISO year containing the given date
Q Returns the first day of the quarter containing the given date
MONTH, MON, MM, RM Returns the first day of the specified month
WW Returns the largest date just prior to, or the same as the given date that corresponds to the same day of the week as the first day of the year
IW Returns the start of the ISO week containing the given date
W Returns the largest date just prior to, or the same as the given date that corresponds to the same day of the week as the first day of the month
DDD, DD, J Returns the start of the day for the given date
DAY, DY, D Returns the start of the week (Sunday) containing the given date
HH, HH12, HH2 4 Returns the start of the hour
MI Returns the start of the minute

## TRUNC函数示例

``````SELECT TO_CHAR(TRUNC(TO_DATE('1951','YYYY'),'CC'),'DD-MON-YYYY') "Century" FROM DUAL;

Century
-------------
01-JAN-1901
(1 row)    ``````

``````SELECT TO_CHAR(TRUNC(TO_DATE('01-JUL-1999','DD-MON-YYYY'),'Y'),'DD-MON-YYYY') "Year" FROM DUAL;

Year
-------------
01-JAN-1999
(1 row)``````

``````SELECT TO_CHAR(TRUNC(TO_DATE('01-JUL-2004','DD-MON-YYYY'),'IYYY'),'DD-MON-YYYY') "ISO Year" FROM DUAL;

ISO Year
-------------
29-DEC-2003
(1 row)        ``````

``````SELECT TRUNC(TO_DATE('16-FEB-07','DD-MON-YY'),'Q') "Quarter" FROM DUAL;

Quarter
--------------------
01-JAN-07 00:00:00
(1 row)    ``````

``````SELECT TRUNC(TO_DATE('16-DEC-07','DD-MON-YY'),'MONTH') "Month" FROM DUAL;

Month
--------------------
01-DEC-07 00:00:00
(1 row)``````

``````SELECT TRUNC(TO_DATE('19-JAN-07','DD-MON-YY'),'WW') "Week" FROM DUAL;

Week
--------------------
15-JAN-07 00:00:00
(1 row)``````

``````SELECT TRUNC(TO_DATE('02-JAN-04','DD-MON-YY'),'IW') "ISO Week" FROM DUAL;

ISO Week
--------------------
29-DEC-03 00:00:00
(1 row)``````

``````SELECT TRUNC(TO_DATE('21-MAR-07','DD-MON-YY'),'W') "Week" FROM DUAL;

Week
--------------------
15-MAR-07 00:00:00
(1 row)``````

``````SELECT TRUNC(TO_DATE('04-AUG-07 12:00:00 PM','DD-MON-YY HH:MI:SS AM'),'J') "Day" FROM DUAL;

Day
--------------------
04-AUG-07 00:00:00
(1 row)``````

``````SELECT TRUNC(TO_DATE('09-AUG-07','DD-MON-YY'),'DAY') "Day of Week" FROM DUAL;

Day of Week
--------------------
05-AUG-07 00:00:00
(1 row)``````

``````SELECT TO_CHAR(TRUNC(TO_DATE('09-AUG-07 08:30','DD-MON-YY HH:MI'),'HH'),'DD-MON-YY HH24:MI:SS') "Hour" FROM DUAL;

Hour
--------------------
09-AUG-07 08:00:00
(1 row)``````

``````SELECT TO_CHAR(TRUNC(TO_DATE('09-AUG-07 08:30:30','DD-MON-YY HH:MI:SS'),'MI'),'DD-MON-YY HH24:MI:SS') "Minute" FROM DUAL;

Minute
--------------------
09-AUG-07 08:30:00
(1 row)``````