In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "mysql how to set time query conditions", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "mysql how to set time query conditions" article.
Method: 1, use "DATE_ADD (date,INTERVAL expr type)" to add the specified time interval to the date; 2, use "DATE_SUB (date,INTERVAL expr type)" to subtract the specified time interval from the date; 3, use the "TO_DAYS" function, and so on.
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
How to set the time query condition by mysql
DATE_ADD () function
The DATE_ADD () function adds the specified time interval to the date.
DATE_ADD (date,INTERVAL expr type)
The date parameter is a valid date expression. The expr parameter is the interval you want to add.
Type parameters can be the following values: SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR, etc.
DATE_SUB function
The DATE_SUB function subtracts the specified interval from the date.
DATE_SUB (date,INTERVAL expr type)
The date parameter is the date expression of Hefei. The expr parameter is the interval you want to add.
Type parameters can be the following values: SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR, etc.
DATE_FORMAT () function
The DATE_FORMAT () function is used to display date / time data in different formats
DATE_FORMAT (date,format)
The date parameter is the date. Format specifies the output format of date / time, which can be the following values:% h hour 01-12,% m month,% s seconds,% y year 2 digits
TO_DAYS () function
Calculate the number of days from the beginning of the year to a given time.
FROM_UNIXTIME () function
Timestamp turns date, notice that the timestamp in mysql is 10 digits.
UNIX_TIMESTAMP () function
Date to time stamp
SELECT NOW () FROM DUALSELECT to_days (now ()) FROM DUALSELECT date_format (now (),'% YMY% MMI% d') FROM DUALSELECT DATE_SUB (NOW (), INTERVAL 3 DAY) FROM dualSELECT DATE_ADD (NOW (), INTERVAL 3 DAY) FROM dual is the content of this article on "how to set time query conditions for mysql". I believe you all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about it, please 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.