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

How do we offload time/date processing in MySQL?

WBOY
WBOYforward
2023-09-05 12:45:02711browse

我们如何卸载 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)

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)

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete