How to convert the varchar type into the date type in MySQL, varchardate

Source: Internet
Author: User

How to convert the varchar type into the date type in MySQL, varchardate

See the following table:

Use the str_to_date function to convert the varchar type to the date type, and then sort the data from small to large.

Syntax: select str_to_date (class_time, '% Y % m % d % H: % I: % s') a from a order by a desc;

Next, let's take a look at the conversion of the varchar type date format in oracle to the date type.

Convert varchar-type date format to 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. The date type is converted first.

(Hours, minutes, or seconds must be added; otherwise, a ora-01830 error is reported)

And convert it to the varchar type as needed.

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.