Home > Database > Mysql Tutorial > How do we offload time/date processing in MySQL?

How do we offload time/date processing in MySQL?

WBOY
Release: 2023-09-05 12:45:02
forward
718 people have browsed it

我们如何卸载 MySQL 中的时间/日期处理?

We can offload time/date processing to MySQL with the help of the DATE_FORMAT() function. The date and time will be unloaded according to the format units passed as arguments to the function.

For example, when we pass the date format unit as a parameter to the MySQL DATE_FORMAT() function, MySQL only unloads the date as follows -

mysql> Select DATE_FORMAT("2017-10-22 13:03:45", "%Y %M %D")AS 'OFFLOADED DATE';
+-------------------+
| OFFLOADED DATE    |
+-------------------+
| 2017 October 22nd |
+-------------------+
1 row in set (0.00 sec)
Copy after login

However, when we pass the time format unit as a parameter to MySQL only unloads the time when using the DATE_FORMAT() function as shown below -

mysql> Select DATE_FORMAT("2017-10-22 13:03:45", "%h %i %s %p")AS 'OFFLOADED TIME';
+----------------+
| OFFLOADED TIME |
+----------------+
| 01 03 45 PM    |
+----------------+
1 row in set (0.00 sec)
Copy after login

The above is the detailed content of How do we offload time/date processing in MySQL?. 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