Home > Database > Mysql Tutorial > body text

How to convert mysql var to date

藏色散人
Release: 2020-10-26 15:33:21
Original
3442 people have browsed it

Mysql var to date method: First use the str_to_date function to convert its varchar type to date type; then sort from small to large.

How to convert mysql var to date

Recommended: "mysql video tutorial"

The following table:

First use the str_to_date function to 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 a order by a desc ;

## Let’s take a look at the date format of varchar type in Oracle Convert date type

Convert date format from varchar type in oracle

SELECT to_char(to_date(m.ma_datetime,'yyyy-MM-dd hh24:mi:ss'),
 'yyyyMMdd') FROM my_task m;
Copy after login

m.ma_datetime is a date format of varchar2 type, first convert date type


(Must add hours, minutes and seconds, otherwise ora-01830 error will be reported)


Then convert it to varchar type as you like

The above is the detailed content of How to convert mysql var to date. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template