In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 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.
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.