Plsql_ Basic Series 9_ timestamp timestamp

Source: Internet
Author: User

2013-11-09 Baoxinjian

1. Get the System time statement (Ssxff6 get six digits after the decimal point)

Select ' YYYYMMDD Hh24:mi:ssxff6 '),  'yyyymmdd hh24:mi:ss.ff6' from

2. Turn the character into timestamp

Select to_timestamp ('2011-09-14 12:52:42.123456789'syyyy-mm-dd Hh24:mi:ss.ff' from dual;

3. Timestamp turns into date type

Select cast (To_timestamp ('2011-09-14 12:52:42.123456789'syyyy-mm-dd hh24: Mi:ss.ff' as from dual;

4. Date type turns into timestamp

Select cast  as timestamp  from dual;

5. The date of two is subtracted by the number of days, and the date of the two timestamp is subtracted from the full month day seconds

SelectSysdate-Sysdate,systimestamp-Systimestamp fromdual;SelectExtract Day  fromInter*  - *  - *  - +Extract (Hour fromInter*  - *  - +Extract (minute fromInter*  - +Extract (Second frominter) "Seconds" from(  SelectTo_timestamp ('2011-09-14 12:34:23.281000000','YYYY-MM-DD hh24:mi:ss.ff')-To_timestamp ('2011-09-14 12:34:22.984000000','YYYY-MM-DD hh24:mi:ss.ff') Inter fromdual); SelectExtract (second fromTo_timestamp ('2011-09-14 12:34:23.281000000','YYYY-MM-DD hh24:mi:ss.ff'))-Extract (Second fromTo_timestamp ('2011-09-14 12:34:22.984000000','YYYY-MM-DD hh24:mi:ss.ff')) fromDual

Note: So, timestamp to figure out the two date interval of how many seconds, to use a function to convert.

The TO_CHAR function supports date and timestamp, but Trunc does not support timestamp data types.

Plsql_ Basic Series 9_ timestamp timestamp

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.