In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to query the data of a certain day in mysql". In the daily operation, I believe that many people have doubts about how to query the data of a certain day in mysql. The editor has consulted all kinds of materials and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the doubt of "how to query the data of a certain day by mysql". Next, please follow the editor to study!
Methods: 1. Using the "date_format" function, the syntax "where date_format (date,'%Y-%m-%d') = 'year-month-day'"; 2, using the datediff function, the syntax "WHERE (time,' year-month-day') = 0".
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
How does mysql query the data of a certain day?
1. DATE_FORMAT function
The WHERE (datediff (time,' year-month-day') = DATE_FORMAT () function is used to display date / time data in different formats.
Grammar
DATE_FORMAT (date,format)
The date parameter is a legal date. Format specifies the output format of the date / time.
Examples are as follows:
Select * from [table_name] where date_format ([date_name],'% Ymuri% mmuri% d') = '2022-05-13'
2. DATEDIFF function
The DATEDIFF () function returns the number of days between two dates.
Grammar
DATEDIFF (date1,date2)
The date1 and date2 parameters are valid date or date / time expressions.
Examples are as follows:
SELECT * FROM [table_name] WHERE (datediff (update_time, '2022-05-13') = 0)
Expand knowledge:
SELECT * FROM [table_name] WHERE substring (Convert (char (10), update_time) 1Mei8) = '20220513' SELECT * FROM [table_name] WHERE update_time between' 2022-05-13 0000 SELECT 00' and '2022-05-13 2323 Weather 59' SELECT * FROM [table_name] WHERE year (update_time) = 2022 and month (update_time) = 05 and day (update_time) = 13SELECT * FROM [table_name] WHERE update_time >' 2017-09-27' and update_time < '2022-05-13' so far The study on "how to query the data of a certain day by mysql" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.