Select To_char (sysdate, ' Yyyy-mm-dd hh24:mi:ss ') from dual; --Show Current time
2011-12-29 16:24:34
Select Trunc (Sysdate, ' year ') from dual; -Interception to year (first day of this year)
2011-1-1
Select Trunc (sysdate, ' Q ') from dual; -Intercept to quarter (first day of the quarter)
2011-10-1
Select Trunc (sysdate, ' month ') from dual; -Interception to the month (first day of the month)
2011-12-1
Select Trunc (sysdate, ') from dual;
Empty
Select To_char (trunc (sysdate), ' Yyyymmdd Hh24:mi:ss ') from dual; --Default intercept to day (0 minutes and 0 seconds of the day)
20111229 00:00:00
Select Trunc (sysdate-1, ' W ') from dual; --The most recent Thursday from the current time, if the day is Thursday then return the same day, otherwise return to Thursday
2011-12-22
Select Trunc (sysdate, ' WW ') from dual; --Interception to last weekend (last Saturday)
2011-12-24
Select Trunc (sysdate, ' Day ') from dual; -Intercept to week (first day of the week, Sunday)
2011-12-25
Select Trunc (sysdate, ' IW ') from dual; 2nd Day of the week, this Monday
2011-12-26
Select To_char (trunc (sysdate, ' DD '), ' YYYYMMDD hh24:mi:ss ') from dual;--intercept to day (0 minutes 0 seconds of the day)
20111229 00:00:00
Select Trunc (sysdate, ' hh24 ') from dual; --intercept to hours (current hour, 0 minutes 0 seconds)
2011-12-29 16:00:00
Select Trunc (sysdate, ' mi ') from dual; --intercept to points (current minute, 0 seconds)
2011-12-29 16:24:00
Select Trunc (sysdate, ' SS ') from dual;--error, no accurate to second format
Oracle TRUNC functions handle date formats, date types are useful for several SQL