In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
What this article shares with you is about simplicity! Just one step to help you use mysql to achieve date and time query content. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.
Select now ();-- current date and time 2018-07-25 14:29:36select LAST_DAY ('2018-02-01');-- return to the last day of the month 2018-02-28select DATE_FORMAT (now (),'% Y-%m-%d% HRV% mRV% S')-- formatted output 2018-07-25 14:07:18select '2018-07-25' = (select DATE_FORMAT (now (),'% Y% m color% d')) -- determine whether the current date is equal to the specified date. Return 0 means unequal, 1 means equal 1set @ dt= (SELECT DATE_FORMAT (now (),'% Y-%m-%d% H15% iRover% s'));-- format the current date and time and assign it to @ dt SELECT @ dt;--2018-07-25 14:33:50SELECT DATE (@ dt);-- 2018-07-25SELECT TIME (@ dt) -- 14:33:50SELECT DATE (NOW ());-- only current date 2018-07-25SELECT TIME (NOW ());-- only current time 14:36:19SELECT YEAR (now ());-- 2018SELECT month (now ());-- 7select day (now ());-- 25SELECT time (now ()) time1, sleep (3), time (now ()) time2 The time for time1 and time2 is the same at 14:43:54 0 14:43:54SELECT time (SYSDATE ()) time1,sleep (3), time (SYSDATE ()) time2. -- the time difference between time1 and time2 for 3s sleep time: 3s 14:43:15 014GV 43min 18MZ-other functions that get the current date and time: select CURRENT_DATE,CURRENT_TIME,CURRENT_USER,LOCALTIME,LOCALTIMESTAMP,date (LOCALTIME), date (LOCALTIMESTAMP), time (LOCALTIME) -- 2018-07-25 14:48:30 root@localhost 2018-07-25 14:48:30 2018-07-25 14:48:30 2018-07-25 2018-07-25 14:48:30set @ dt='2018-02-14 14 Poll 22 23' SELECT DAYOFMONTH ('2018-02-14')-day of January 14SELECT DAYOFWEEK ('2018-02-14')-day of the week Note: 4SELECT DAYOFYEAR (@ dt)-day of the year 45select WEEKOFYEAR (@ dt)-week 7 of the year
Format the date value according to the format string:
% S,% s two-digit seconds (000001,..., 59)
% I,% I score in two-digit form (005001,..., 59)
% H double-digit hours, 24 hours (000001,., 23)
% h double-digit hours, 12 hours (01Jing 02,., 12)
% k hours in digital form, 24 hours (0Jol 1,..., 23)
L hours in digital form, 12 hours (1, 2,., 12)
% T 24-hour time form (hh:mm:ss)
% r time form of 12 hours (hh:mm:ss AM or hh:mm:ss PM)
% p AM or PM
% W name of every day of the week (Sunday, Monday,..., Saturday)
% an abbreviation of the name of every day of the week (Sun, Mon,..., Sat)
% d double digits indicate the number of days in the month (0001, 31)
The numeric form of% e represents the number of days in the month (1, 2,. 31)
The% D suffix denotes the number of days in the month (1st, 2nd, 3Rd, etc.)
% w represents the number of days of the week in numeric form (0 = Sunday, 1=Monday,..., 6=Saturday)
% j represents the number of days of the year in three digits (00002,., 366)
% U week (0,1,52), where Sunday is the first day of the week
% u week (0,1,52), where Monday is the first day of the week
% M month name (January, February,..., December)
% b abbreviated month name (January, February,...., December)
% m double-digit month (01,02,..., 12)
Month represented by% c number (1, 2,., 12)
Year represented by% Y four digits
Year represented by% y double digits
% Direct value'%'
Thank you for reading! About simplicity! Just one step to help you use mysql to achieve date and time query to share here, I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.
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.