Thursday, June 29, 2006

Oracle : SQL : TRUNC Function with DATE

The TRUNC Function can be used with a DATE Datatype to get interesting results. The TRUNC can be used to get the First Day of the Month, First Day of the year, etc.

SQL> SELECT TRUNC(SYSDATE,'YYYY') FROM DUAL;

TRUNC(SYS
---------
01-JAN-06

SQL> SELECT TRUNC(SYSDATE,'MM') FROM DUAL;

TRUNC(SYS
---------
01-JUN-06

No comments: