Select To_char (sysdate, ' yyyy-mm-dd hh24:mi:ss '), To_char (Trunc (sysdate), ' Yyyy-mm-dd Hh24:mi:ss ') from dual T;--sysdate and Trunc (sysdate) are not the same sysdate on the day of zero 0 minutes 0 seconds equals trunc (sysdate) Select Trunc (sysdate, ' DD '), Trunc (Sysdate) FR Om dual T; --Today at 201,407,030, 0 minutes, 0 seconds, select To_char (trunc (sysdate, ' DD '), ' Yyyy/mm/dd hh24:mi:ss '), To_char (Trunc (sysdate), ' yy
Yy/mm/dd Hh24:mi:ss ') from dual; Select Trunc (sysdate-to_date (' 20140709 23:12:12 ', ' yyyy/mm/dd hh24:mi:ss ')) from dual t;--the number of days between two dates select Trunc ( sysdate-1) from dual t;--yesterday select Trunc (sysdate+1) from dual t;--tomorrow Select Trunc (sysdate, ' yy ') from dual;-- The first day of select Trunc (Sysdate, ' year ') from dual;--, the first day of select Trunc (sysdate, ' yyyy ') from dual;--the first day of the year select TR UNC (sysdate, ' Q ') from dual;--the first day of the quarter on which the current time is located select Trunc (sysdate, ' mm ') from dual;--the first day of the month select Trunc (sysdate, ' Month ') from dual;--the first day of the month select Trunc (sysdate, ' d ') from dual;--Returns the first day of the week (Sunday is the first day) Select Trunc (sysdate, "Day") from dual;--returns the first day of the week (Sunday is the first) select Trunc (sysdate, ' IW ') from dual --the second day of this week (Sunday is the first day) Select Trunc (sysdate, ' hh ') from dual; --current time, accurate to hour select Trunc (sysdate, ' hh24 ') from dual;--current time, accurate to hour select Trunc (sysdate, ' mi ') from dual;--current time, Accurate to minute accuracy without precision to second
/* TRUNC (number,num_digits)
number requires a truncated integer.
num_digits is used to specify the number of rounding precision. The default value for Num_digits is 0.
a positive number is intercepted, and a negative number is intercepted
forward TRUNC () function is intercepted without rounding/
select TRUNC (123.458) from dual;--123
Select TRUNC (123.458, 0) from dual;
Select Trunc (123.458, 1) from dual;--123.4
Select Trunc (123.458,-1) from dual;--120
Select Trunc (123.45 8,-4) from dual; --0
Select Trunc (123.458, 4) from dual;--123.458
select Trunc (123) from dual;--123
Select Trunc (123, 1) F ROM dual; --123
Select Trunc (123,-1) from dual;--120
This column more highlights: http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/