Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement date formatting in MySQL

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you "MySQL how to achieve date formatting", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "MySQL how to achieve date formatting" this article.

Date formatting

Command: select date_format (now (),'% y-%m-%d).

Function: format the date.

Application scenario: when formatting a date.

Example:

Mysql > select date_format (now (),'% ymuri% mme% d') +-- + | date_format (now () '% yMel% mMel% d') | +-+ | 17-12-28 | +-- + 1 row in set (0.00 sec)

The formats supported here are:

% y: represents a year (double digits), for example: 17 years.

% Y: represents a 4-digit year, for example: 2017

% m: represents month (1-12)

% d: represents the day of the month

% H: hours (0-23)

% I: minutes (0-59)

% s: seconds (0-59)

Month, day, hour and second:% y-%m-%d% H:%i:%s

As follows:

Mysql > select DATE_FORMAT (now (),'% y-%m-%d% HRV% iRO% s') +-- + | DATE_FORMAT (now () '% y-%m-%d% HRV% iRV% s') | +-+ | 17-12-27 20:28:54 | +-- + 1 row in set (0. 00 sec) these are all the contents of the article "how to format dates in MySQL" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report