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

Mysql date format operation

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly explains "mysql date formatting operation", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "mysql date formatting operation"!

mysql Date

DATE_FORMAT(date,format)

Format date values according to the format string. The following modifiers can be used in format strings:

%M Month Name (January…December)

%W Name of week (Sunday…Saturday)

%D Date of month with English prefix (1st, 2nd, 3rd, etc.)

%Y year, number, 4 digits

%y year, number, 2 digits

%a Abbreviated week name (Sun... Sat)

%d Days in month, number (00……31)

%e Days in month, number (0……31)

%m Month, Number (01……12)

%c month, number (1……12)

%b Abbreviated month name (Jan…Dec)

%j Days of the year (001……366)

%H hours (00……23)

%k hours (0……23)

%h hours (01……12)

%I hours (01……12)

%l hours (1……12)

%i minutes, number (00……59)

%r Time, 12 hours (hh:mm:ss [AP]M)

%T time, 24 hours (hh:mm:ss)

%S seconds (00……59)

%s seconds (00……59)

%p AM or PM

%w Days of the week (0=Sunday …6=Saturday)

%U Week (0……52), where Sunday is the first day of the week

%u Week (0……52), where Monday is the first day of the week

%%A word "%".

DATE_FORMAT(NOW(),'%b %d %Y %h:%i %p')DATE_FORMAT(NOW(),'%m-%d-%Y')DATE_FORMAT(NOW(),'%d %b %y')DATE_FORMAT(NOW(),'%d %b %Y %T:%f')select str_to_date('09/01/2009','%m/%d/%Y')select str_to_date('20140422154706','%Y%m%d%H%i%s')select str_to_date('2014-04-22 15:47:06','%Y-%m-%d %H:%i:%s')selectcurdate ();--get current dateselectlast_day(curdate());--get current month last day. selectDATE_ADD (curdate(),interval-day (curdate())+1day);--Get the first day of the month selectdate_add (curdate()-day (curdate())+1,interval1month);--Gets the first day of the next month selectDATEDIFF (date_add(curdate()-day (curdate())+1,interval1month),DATE_ADD(curdate(),interval-day(curdate())+1day))fromdual;--Get the days of the current month Here, I believe you have a deeper understanding of "mysql date formatting operation", you may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

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: 223

*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