Home > Database > Mysql Tutorial > body text

How can we use MySQL function STR_TO_DATE(Column, '%input_format')?

王林
Release: 2023-09-06 14:57:03
forward
677 people have browsed it

我们如何使用 MySQL 函数 STR_TO_DATE(Column, ‘%input_format’)?

STR_TO_DATE() function converts a string value into a datetime value, and it will format the string according to a specific format. Both string values ​​and format strings must be passed as arguments to the function. Following is the syntax of STR_TO_DATE() function.

STR_TO_DATE(string, format)
Copy after login

The string here is the string value that needs to be converted to a date and time value, and the format is the specified date format.

The following example will return a valid date from the given string according to the specified format.

mysql> Select STR_TO_DATE('20172810', '%Y%d%m');
+-----------------------------------+
| STR_TO_DATE('20172810', '%Y%d%m') |
+-----------------------------------+
| 2017-10-28                        |
+-----------------------------------+
1 row in set (0.00 sec)
Copy after login

The above is the detailed content of How can we use MySQL function STR_TO_DATE(Column, '%input_format')?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!