Oracle:
1. Get the current date of the year, month, day, time, minute, second
SelectTo_char (Sysdate,'yyyy') asNowyear fromDual//get the year of the time SelectTo_char (Sysdate,'mm') asNowmonth fromDual//get the month of the time SelectTo_char (Sysdate,'DD') asNowday fromDual//get the day of the time SelectTo_char (Sysdate,'hh24') asNowhour fromDual//when you get the time SelectTo_char (Sysdate,'mi') asNowminute fromDual//get the minutes of the time SelectTo_char (Sysdate,'SS') asNowsecond fromDual//gets the seconds of the time
View Code
2. What is the day of the week?
Select to_char (sysdate,'dy'fromselect to_char (to_ Date ('20170725','yyyy/mm/dd'),'day ' from dual // results: 2017-07-25
3. Days between two dates (Oracle database Two date subtraction is number of days)
Select Floor (sysdate-to_date ('20170725','yyyy-mm-dd') from dual; Select to_char (sysdate-to_date ('20170725','yyyy-mm-dd ' from dual; // returns the number of days with a decimal point
4. Number of months between two dates
Select Floor (Months_between (sysdate,to_date ('20170725',' Yyyy-mm-dd' from dual;
5. See how many days this year
Select add_months (trunc (sysdate,'year')-Trunc (Sysdate, ' Year ' from dual
6. Set the date language
set nls_date_language=' simpleChinese'set nls_date_language ='American';
Usage of 7.next_day (date,day)
Date represents the day, which represents the week, or 1-7.
Select from dual; // Next Thursday
The above is the use of some of Oracle's time and date, should not have installed the relevant software, code is based on some of the information on the Internet written out, has not been verified, so did not write the results, later verification will be added.
MySQL vs Oracle (III)---date comparison (Oracle)