Mysql to convert the varchar type to date type method detailed _mysql

Source: Internet
Author: User

As shown in the following table:

Use the Str_to_date function first, convert its varchar type to date type, and then sort from small to large

Syntax: Select Str_to_date (class_time, '%y%m%d%h:%i:%s ') A from an order by a desc;

Next, let's look at the date format conversion dates type of varchar in Oracle

varchar type date format conversion date type in Oracle

SELECT To_char (to_date (m.ma_datetime, ' yyyy-mm-dd hh24:mi:ss '),
 ' YyyyMMdd ') from my_task m;

M.ma_datetime is the date format of the VARCHAR2 type, first converting the date type

(must be added minutes or seconds, otherwise reported ora-01830 error)

And then convert to varchar type at whim.

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.