In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces how to format time in MySQL, the content is very detailed, interested friends can use for reference, I hope it can be helpful to you.
The DATE_FORMAT () function is used to display date / time data in different formats.
Usage
Select DATE_FORMAT (date,format) from table
The date parameter is a legal date.
Format specifies the date / time output format, which can have the following format:
% an abbreviated week name% b abbreviated month name% c month, value% D day of month with English prefix% d month, value (00-31)% e-month day, value (0-31)% f microsecond% H-hour (00-23)% h-hour (01-12)% I-hour (01-12)% I minute Value (00-59)% j year day (001-366)% k hour (0-23)% l hour (1-12)% M month name% m month, value (00-12)% p AM or PM% r time 12-hour (hh:mm:ss AM or PM)% S seconds (00-59)% s seconds (00-59)% T time, 24-hours (hh:mm:ss)% U week (00-53) Sunday is the first day of the week% u week (00-53) Monday is the first day of the week% V week (01-53) Sunday is the first day of the week With% X using% v week (01-53) Monday is the first day of the week, with% x using% W week name% w week day (0 = Sunday, 6 = Saturday)% X year, where Sunday is the first day of the week, 4 digits, and% V using% x year, where Monday is the first day of the week, 4 digits, and% v using% Y year, 4 digits% y year 2 bit
Examples
Select DATE_FORMAT (now (), "% Y-%m-%d% H:%i:%S") as now
Output
Mysql > select DATE_FORMAT (now (), "Y-%m-%d H:%i:%S") as now +-+ | now | +-+ | 0-11-02 22:06:40 | +-+ 1 row in set (sec)
Statistics by date
Select create_day, count (1) AS count from (select DATE_FORMAT (CREATE_TIME, "% Y-%m-%d") AS create_day FROM TABLES) u group by create_day
Output
Mysql > select create_day, count (1) AS count from (select DATE_FORMAT (CREATE_TIME, "% Y-%m-%d") AS create_day FROM TABLES) u group by create_day +-+-+ | create_day | count | +-10-+ | 2020-10-26 | 323 | +-+-+ 1 row in set (0.00 sec) this is the time to share about how to format in MySQL. I hope the above content can be of some help to you. You can learn more. If you think the article is good, you can share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.