Common SQL statements:
Select To_char (sysdate, ' Yy-mm-dd hh24:mi:ss ') from dual; Display: 08-11-07 13:22:42
Select To_date (' 2005-12-25,13:25:59 ', ' Yyyy-mm-dd,hh24:mi:ss ') from dual; Display: 2005-12-25 13:25:59
Get system time:
Select Sysdate from dual;
Format of conversion:
Represents year's: Y represents the last 2 digits of the year yyy represents the last 3 digits of the year yyyy in 4-digit years
MM with 2 digits for month; Mon in abbreviated form such as November or Nov; month with full name such as November or November
Indicates day: DD indicates days of the month, DDD indicates the day of the year, DY when in for a few days, such as Friday or Fri;day when in a few days to write all
Like Friday or Friday.
Represents hour: HH 2 digits for hour 12, hh24 2 digits for hours 24 hours
Time range under 24-hour system: 00:00:00-23:59:59
Time range under 12-hour system: 1:00:00-12:59:59
Represents minute: Mi 2 digits for minutes
Represents second: SS 2 digits for seconds 60 binary
Indicates quarterly: Q A number represents quarter (1-4)
There is also WW used to indicate the week of the year when W is used to denote the month ordinal.
Add:
Time minus 7 minutes for the current time
Select Sysdate,sysdate-interval ' 7 ' MINUTE from dual
The current time minus 7 hours of time
Select Sysdate-interval ' 7 ' hour from dual
The current time minus 7 days
Select Sysdate-interval ' 7 ' Day from dual
Time minus July for current time
Select Sysdate,sysdate-interval ' 7 ' month from dual
Time minus 7 years in the current time
Select Sysdate,sysdate-interval ' 7 ' year from dual
Time interval multiplied by a number
Select Sysdate,sysdate-8*interval ' 7 ' hour from dual
Reference: http://www.cnblogs.com/gaojing/archive/2008/11/07/1328657.html