TRUNC () function --oracle

Use trunc () function to get a different date:

 SELECT the trunc (SYSDATE) from Dual;   - today's date 
 SELECT the trunc (SYSDATE, ' dd ' ) from Dual;   - Returns the current date 
 SELECT the trunc (SYSDATE, ' mm ' )    from    Dual;   - returns the first of the month . days 
 SELECT TO_CHAR (the trunc (ADD_MONTHS (LAST_DAY (SYSDATE), - . 1 ) +  . 1 ), ' YYYY-mm-dd ' ) from Dual; - obtaining a first day of the month 
 SELECT TO_CHAR (LAST_DAY (SYSDATE), 'mm-dd-YYYY ' ) from Dual; - obtaining the last day of the month 
 SELECT the trunc (SYSDATE, ' YY ' ) from Dual; - returns to the first day of the year 
 SELECT the trunc (SYSDATE, ' YYYY ' ) from Dual; - then back to the first day of 
 the SELECT trunc (sysdate, ' d ' ) from Dual; - return to the first day of the current week (Sunday, Monday date) 
 the SELECT trunc (sysdate, ' HH ' ) from Dual;   - the current time accurate to hours
 SELECT the trunc (SYSDATE, ' mi The ' ) from Dual; - the current time to the nearest second, however TRUNC () function does not precisely seconds

 

Guess you like

Origin www.cnblogs.com/liujiale/p/10937860.html