The following articles mainly describe the actual operation steps of time processing in the Oracle database. We will describe the instance in the form of 4824 hours, and we will use HH24 to display it, the following is an analysis of the specific content of the article. I hope you will gain some benefits.
- select to_char(sysdate,'yyyy-MM-dd HH24:mi:ss') from dual;
- select to_date('2005-01-01 13:14:20','yyyy-MM-dd HH24:mi:ss') from dual;
- to_date() function
1. Description of date format parameters
D. day of the week
The name of DAY, which is filled with spaces to 9 characters.
Day of DD month
The day of the year in DDD
Short Name of DY day
Week of the Year of the iw iso Standard
Four-digit year of the iyyy iso Standard
YYYY four-digit year
Last three digits of YYY, YY, and Y years, two digits, one digit
HH hours, at 12 hours
HH24 hours, in 24 hours
MI score
SS seconds
MM Month
Abbreviated month of Mon
Full name of Month
W the week of the month
The day of the week in WW 1. Date interval operation
Current Time minus 7 minutes
- select sysdate,sysdate - interval '7' MINUTE from dual
Current Time minus 7 hours
- select sysdate - interval '7' hour from dual
Current Time minus 7 days
- select sysdate - interval '7' day from dual
Current Time minus July
- select sysdate,sysdate - interval '7' month from dual
Current Time minus 7 years
- select sysdate,sysdate - interval '7' year from dual
Time Interval multiplied by a number
- select sysdate,sysdate - 8 *interval '2' hour from dual
2. Date-to-character operations
- select sysdate,to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual
- select sysdate,to_char(sysdate,'yyyy-mm-dd hh:mi:ss') from dual
- select sysdate,to_char(sysdate,'yyyy-ddd hh:mi:ss') from dual
- select sysdate,to_char(sysdate,'yyyy-mm iw-d hh:mi:ss') from dual
Refer to the Oracle database documentation (ORACLE901DOC/SERVER.901/A90125/SQL _ELEMENTS4.HTM #48515)
3. Character-to-date operations
- select to_date('2003-10-17 21:15:37','yyyy-mm-dd hh24:mi:ss') from dual
The usage is similar to that of to_char.