the use of the--oracle trunc () function
/************** Date ********************/
Select Trunc (sysdate) from dual--2011-3-18 today's date is 2011-3-18
Select Trunc (sysdate, ' mm ') from dual--2011-3-1 Returns the first day of the month.
Select Trunc (sysdate, ' yy ') from dual--2011-1-1 Returns the first day of the year
Select Trunc (sysdate, ' DD ') from dual--2011-3-18 return to current month day
Select Trunc (sysdate, ' yyyy ') from dual--2011-1-1 Returns the first day of the year
Select Trunc (sysdate, ' d ') from dual--2011-3-13 (Sunday) returns the first day of the current week
Select Trunc (sysdate, ' hh ') from dual--2011-3-18 14:00:00 Current time is 14:41
Select Trunc (sysdate, ' mi ') from dual--2011-3-18 14:41:00 TRUNC () function does not have the exact second
/*************** Digital ********************/
/*
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.
TRUNC () function is not rounded when truncated
*/
Select Trunc (123.458) from dual--123
Select Trunc (123.458,0) from dual--123
Select Trunc (123.458,1) from dual--123.4
Select Trunc (123.458,-1) from dual--120
Select Trunc (123.458,-4) from dual--0
Select Trunc (123.458,4) from dual--123.458
Select Trunc (123) from dual--123
Select Trunc (123,1) from dual--123
Select Trunc (123,-1) from dual--120
Use of the Oracle trunc () function