a system time
1. Grammar
SYSDATE
Default format: DD-MON-RR (day month year)
2. Examples
SQL>select sysdate from dual;
SYSDATE
--------------
02-7月-17
two-day operation
1. Grammar
ADD_MONTHS(date,i): Returns the month added to the specified date.
i can be any integer, if i is a decimal, the integer part is truncated
If i is negative, it is equivalent to subtracting the month from the original date.
NEXT_DAY
(date,char)
If the value of char is 'Monday', returns the next Monday hour of the date specified by date.
LAST_DAY(date): Returns the last day of each month.
MONTH_BETWEEN(date1,date2)
EXTRACT(date from datetime)
2. Examples
SQL>select add_months(sysdate,3),add_months(sysdate,-3)from dual;
ADD_MONTHS(SYS ADD_MONTHS(SYS
----------------------------
02-10月-1702-4月-17
SQL>select next_day(sysdate,'星期一')from dual;
NEXT_DAY(SYSDA
--------------
03-7月-17
SQL>select next_day(sysdate,'星期日')from dual;
NEXT_DAY(SYSDA
--------------
09-7月-17
SQL>select last_day(sysdate)from dual;
LAST_DAY(SYSDA
--------------
31-7月-17
SQL>select month_betweens('20-5月-15','10-1月-15')from dual;
select month_betweens('20-5月-15','10-1月-15')from dual
*
第1行出现错误:
ORA-00904:"MONTH_BETWEENS":标识符无效
SQL>select months_between('20-5月-15','10-1月-15')from dual;
MONTHS_BETWEEN('20-5月-15','10-1月-15')
---------------------------------------
4.32258065
SQL>select extract(year from sysdate)from dual;
EXTRACT(YEARFROMSYSDATE)
------------------------
2017
SQL>select extract(month from sysdate)from dual;
EXTRACT(MONTHFROMSYSDATE)
-------------------------
7
SQL>select extract(day from sysdate)from dual;
EXTRACT(DAYFROMSYSDATE)
-----------------------
2
SQL>select extract(hour from timestamp '2017-10-1 17:24:34')from dual;
EXTRACT(HOURFROMTIMESTAMP'2017-10-117:24:34')
---------------------------------------------
17
SQL>