Time Application in Oracle

Source: Internet
Author: User

1. conversion functions
The biggest relationship with the date operation is the two conversion functions: to_date (), to_char ()
To_date () converts the character type to the date type in a certain format:
Specific usage: to_date ('1970-11-27 ', 'yyyy-mm-dd'). The former is a string, and the latter is a conversion date format. Note that the first and second data must be in the correct format.
For example, to_date ('2017-11-27 13:34:43 ', 'yyyy-mm-dd hh24: MI: ss') will get the specific time

Multiple date formats:

Yyyy: Year in four bits
YYY, YY, Y: the last three digits, two digits, or one digit of the year. The default value is the current century.
MM: 01 ~ 12 month number
Month: The month, which contains nine characters. Fill the month with spaces on the right.
Mon: the abbreviation of A Three-character month
WW: week of the year
D: The day of the week
DD: The day of the month.
DDD: The day of the year
Day: The full name of the day, expressed in nine characters, and filled with spaces on the right
HH, hh12: the hour of the day, 12 hexadecimal notation
Hh24: The hour in a day. The value ranges from 00 ~ 23
Mi: minute in an hour
SS: seconds in one minute
Ssss: the number of seconds since midnight

To_char (): Convert the date to a certain format to the character type
SQL> select to_char (sysdate, 'yyyy-mm-dd hh24: MI: ss') time from dual;

Time
-------------------
2004-10-08 15:22:58

Converts the current time to the character type in yyyy-mm-dd hh24: MI: SS format.

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.