Actual time processing steps in Oracle Database

Source: Internet
Author: User

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.

 
 
  1. select to_char(sysdate,'yyyy-MM-dd HH24:mi:ss') from dual;  
  2. select to_date('2005-01-01 13:14:20','yyyy-MM-dd HH24:mi:ss') from dual;  
  3. 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

 
 
  1. select sysdate,sysdate - interval '7' MINUTE from dual 

Current Time minus 7 hours

 
 
  1. select sysdate - interval '7' hour from dual 

Current Time minus 7 days

 
 
  1. select sysdate - interval '7' day from dual 

Current Time minus July

 
 
  1. select sysdate,sysdate - interval '7' month from dual 

Current Time minus 7 years

 
 
  1. select sysdate,sysdate - interval '7' year from dual 

Time Interval multiplied by a number

 
 
  1. select sysdate,sysdate - 8 *interval '2' hour from dual 

2. Date-to-character operations

 
 
  1. select sysdate,to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual  
  2. select sysdate,to_char(sysdate,'yyyy-mm-dd hh:mi:ss') from dual  
  3. select sysdate,to_char(sysdate,'yyyy-ddd hh:mi:ss') from dual  
  4. 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

 
 
  1. 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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.