Oracle's solution: to_date (), 24-hour notation, and display of MM minutes

Source: Internet
Author: User
Oracle's solution is to_date () and 24-hour notation and the display of MM minutes:
1. When Oracle's to_date function is used for date conversion, many Program Like me, the engineer may intuitively convert the format "yyyy-mm-dd hh: mm: SS", but it may cause an error in Oracle: "ora 01810 format Code Appears twice ".

For example:Select to_date ('1970-01-01 13:14:20 ', 'yyyy-mm-dd hh24: mm: ss') from dual;

The reason is that SQL statements are case-insensitive. mm and mm are considered to be the same format code, so Oracle SQL uses Mi instead of minutes.

Select To_date ( ' 13:14:20 ' , ' Yyyy-mm-dd hh24: MI: SS ' ) From Dual;

second, it must be displayed in the form of 24 hours with hh24 select to_char (sysdate, ' yyyy-mm-dd hh24: MI: SS ' ) from dual; // Mi is a minute
select to_char (sysdate, ' yyyy-mm-dd hh24: mm: SS ' ) from dual; // MM displays the month

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.