Some common time functions and time operations in El

Source: Internet
Author: User
Code
-- Add_months (A, B)
- From date a plus month B
Select Add_months (sysdate, 5 ) From Dual;

-- to_date (STR, Format)
- time when string-type STR is converted to format
select to_date ( ' 2008-08-01 ' , ' YYYY-MM-DD hh24: MI: SS ' ) from dual;

-- to_char (date, Format)
- convert datetime data to a format string
select to_char (sysdate, ' YYYY-MM-DD hh24: MI: SS ' ) from dual;

-- Add a year to the current date
select sysdate + interval ' 1 ' year from dual

-- Add the current date to April 1, January
select sysdate + interval ' 1 ' month from dual

-- Add one day to the current time
select sysdate + interval ' 1 ' day from dual

-- Add one hour to the current time
select sysdate + interval ' 1 ' hour from dual

-- Add one minute to the current time
select sysdate + interval ' 1 ' minute from dual

-- Add one second to the current time
select sysdate + interval ' 1 ' second from dual

-- trunc (date, 'mm ')
- return the first date of the month of the date.
select trunc (sysdate, ' mm ' ) from dual

-- trunc (date, 'yy ')
-- return the first day of the year where the date is located
select trunc (sysdate, ' YY ' ) from dual

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.