Oracle time and date conversion function ___ static function

Source: Internet
Author: User

Http://hi.baidu.com/cuigq_hr/blog/item/ba2bc167ed79022eaa184c34.html

1. A summary of the dates after the Sysdate conversion:

Select To_char (sysdate, ' yyyy-mm-dd hh24:mi:ss ') today_date,--the time of the day with the seconds
(Sysdate-to_date (' 1970-01-01 ', ' yyyy-mm-dd ')) * 86400-8*3600 Todaytosecond,--today with a minute and a second date converted to seconds later
Trunc (To_date (sysdate)) Today_day,--today's accurate to the day
Trunc (To_date (sysdate + 1)) Tomorrow_day,--tomorrow the day is accurate to the day
(Trunc (To_date (sysdate))-to_date (' 1970-01-01 ', ' YYYY-MM-DD ')] *
86400 + * 3600-8*3600 tomorrow_day--tomorrow's accurate to the second
From dual

2. Second conversion day by day function

Select To_char (to_date (' 19700101 ', ' yyyymmdd ') +
1253030400/86400 + 8/24,--(1253030400 here for your time seconds of conversion all day)
' Yyyy-mm-dd hh24:MI:ss ') secondetoday
From dual

3.select To_number (to_date (' 2009-02-04 23:24:30 ', ' yyyy-mm-dd hh24:MI:ss ')-
To_date (' 2009-02-01 11:21:30 ', ' yyyy-mm-dd hh24:MI:ss '))
from dual;

4. Date type of a day converted to seconds

Select (To_date (' 2009-02-04 23:24:30 ', ' yyyy-mm-dd hh24:MI:ss ')-to_date (' 1970-01-01 ', ' yyyy-mm-dd ')) * 86400-8*3600 Moutiantosecond from dual;--a date converted to seconds after a day with a time

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.