Select To_char (Trunc (Add_months (Last_day (Sysdate),-1) + 1), ' yyyy-mm-dd ') "The first day of the month",
To_char (Last_day (sysdate), ' Yyyy-mm-dd ') "Last day of the month" –oracle trunc () function usage
/************** Date ********************/
1.select trunc (sysdate) from dual–2011-3-18 today's date is 2011-3-18
2.select trunc (sysdate, ' mm ') from Dual–2011-3-1 returns the first day of the month.
3.select trunc (sysdate, ' yy ') from Dual–2011-1-1 returns the first day of the year
4.select trunc (sysdate, ' DD ') from DUAL–2011-3-18 return current month day
5.select trunc (sysdate, ' yyyy ') from Dual–2011-1-1 back to the first day of the year
6.select trunc (sysdate, ' d ') from DUAL–2011-3-13 (Sunday) returns the first day of the current week
7.select trunc (sysdate, ' hh ') from dual–2011-3-18 14:00:00 current time is 14:41
8.select trunc (sysdate, ' mi ') from dual–2011-3-18 14:41:00 trunc () function has no accurate/*************** number of 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.
TRUNC () function is not rounded when truncated
*/
9.select trunc (123.458) from dual–123
10.select trunc (123.458,0) from dual–123
11.select trunc (123.458,1) from dual–123.4
12.select trunc (123.458,-1) from dual–120
13.select trunc (123.458,-4) from dual–0
14.select trunc (123.458,4) from dual–123.458
15.select trunc (123) from dual–123
16.select trunc (123,1) from dual–123
17.select trunc (123,-1) from dual–120
Oracle gets the first day and last day of the month and the use of the Oracle Trunc () function