Select To_char (sysdate, ' yyyy-mm-dd hh24:mi:ss '), To_char (Trunc (sysdate), ' Yyyy-mm-dd Hh24:mi:ss ') from dual T;--sy Sdate and Trunc (sysdate) are not the same sysdate at zero of the day 0 minutes 0 seconds equals trunc (sysdate) Select Trunc (sysdate, ' DD '), Trunc (sysdate) from dual t; --Today 201,407,030 time 0 minutes 0 seconds Select To_char (trunc (sysdate, ' DD '), ' Yyyy/mm/dd hh24:mi:ss '), To_char (Trunc (sysdate), ' yyyy/mm/ DD Hh24:mi:ss ') from Dual;select trunc (The Sysdate-to_date (' 20140709 23:12:12 ', ' yyyy/mm/dd hh24:mi:ss ')) from dual t;-- Two dates difference in days select Trunc (sysdate-1) from dual t;--yesterday select Trunc (sysdate+1) from dual t;--tomorrow Select Trunc (sysdate, ' yy ') from dual;--First day Select Trunc (sysdate, ' year ') from dual;--the first day of the year select Trunc (sysdate, ' yyyy ') from dual;--the first day of the year select Trunc ( Sysdate, ' Q ') from the first day of the quarter on which the current time is dual;--select Trunc (sysdate, ' mm ') from dual;--the first day of the month select Trunc (sysdate, ' month ') from D ual;--the first day of the month select Trunc (sysdate, ' d ') from dual;--returns the first day of the week (Sunday for the first day) Select Trunc (sysdate, ' days ') from dual;-- Returns the first day of the week (Sunday for the first day) Select Trunc (sysdate, ' IW ') from dual;--The next day of the week (Sunday is the first day) Select Trunc (sysdate, ' hh ') from dual; --current time, accurate to hours select Trunc (sysdate, ' hh24 ') from dual;--current time, accurate to hours select Trunc (sysdate, ' mi ') from dual;--current time, accurate to minutes No precision to seconds
/*trunc (number,num_digits) number requires a truncated rounding. The num_digits is used to specify the number of rounding precision. The default value for Num_digits is 0. Positive number is truncated, negative forward intercept trunc () function interception without rounding */select trunc (123.458) from dual; --123select trunc (123.458, 0) from dual; --123select trunc (123.458, 1) from dual; --123.4select trunc (123.458,-1) from dual; --120select trunc (123.458,-4) from dual; --0select trunc (123.458, 4) from dual; --123.458select trunc (123) from dual; --123select trunc (123, 1) from dual; --123select trunc (123,-1) from dual; --120