Home > Database > Mysql Tutorial > body text

How to convert mysql str to date

藏色散人
Release: 2020-10-29 16:47:10
Original
2278 people have browsed it

In mysql, you can use the "STR_TO_DATE(str,format)" function to convert the time format string str into a DATETIME type value according to the provided display format.

How to convert mysql str to date

Recommended: "mysql video tutorial"

STR_TO_DATE(str,format) function is to convert the time The format string (str) is converted into a DATETIME type value according to the provided display format (format). The DATE_FORMAT(date,format) function converts the date in the database into the corresponding string format. It is relatively common and will not be explained.

SELECT STR_TO_DATE('2017-01-06 10:20:30','%Y-%m-%d %H:%i:%s') AS result;
Copy after login

SELECT STR_TO_DATE('2017-01-06 10:20:30','%Y-%m-%d') AS result2;
Copy after login

The above is the detailed content of How to convert mysql str 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