In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you this time is how MySQL to achieve the date addition and subtraction function, the article is rich in content, interested friends can come to understand, I hope you can get something after reading this article.
1. Addtime ()
Add a specified number of seconds to the date
Select addtime (now (), 1);-add 1 second
2. Adddate ()
There are two uses. If the second parameter is to fill in the number directly, it is to add a specified number of days to the date, and to enter interval is to add a specified interval time to the date.
Select adddate (now (), 1);-- 1 day select adddate (now (), interval 1 day);-- 1 day select adddate (now (), interval 1 hour);-- 1 hour select adddate (now (), interval 1 minute);-- 1 minute select adddate (now (), interval 1 second);-- 1 second select adddate (now (), interval 1 microsecond);-- 1 millisecond select adddate (now (), interval 1 week) -- 1 week select adddate (now (), interval 1 month);-- 1 month select adddate (now (), interval 1 quarter);-- 1 season select adddate (now (), interval 1 year);-- 1 year
3. Date_add ()
Add a time interval to the date, which can only use interval time as a parameter, the usage is the same as adddate ()
Select date_add (now (), interval 1 day);-plus 1 day select date_add (now (), interval 1 hour);-- plus 1 hour select date_add (now (), interval 1 minute);-- plus 1 minute select date_add (now (), interval 1 second);-- plus 1 second select date_add (now (), interval 1 microsecond);-plus 1 millisecond select date_add (now (), interval 1 week) -- 1 week select date_add (now (), interval 1 month);-- 1 month select date_add (now (), interval 1 quarter);-- 1 season select date_add (now (), interval 1 year);-- 1 year
4. Subtime ()
Subtract the specified number of seconds from the date
Select subtime (now (), 1);-minus 1 second
5. Subdate ()
Consistent with the adddate () function, there are two uses. The second parameter is to fill in the number directly, minus the specified number of days for the date, and subtract the specified interval time for the date if you fill in interval.
Select subdate (now (), 1);-minus 1 day select subdate (now (), interval 1 day);-minus 1 day select subdate (now (), interval 1 hour);-minus 1 hour select subdate (now (), interval 1 minute);-minus 1 minute select subdate (now (), interval 1 second);-minus 1 second select subdate (now (), interval 1 microsecond);-minus 1 millisecond select subdate (now (), interval 1 week) -minus 1 week select subdate (now (), interval 1 month);-minus 1 month select subdate (now (), interval 1 quarter);-- minus 1 quarter select subdate (now (), interval 1 year);-- minus 1 year
6. Date_sub ()
Consistent with the date_add () function, subtract a time interval from the date, which can only use interval time as an argument
Select date_sub (now (), interval 1 day);-minus 1 day select date_sub (now (), interval 1 hour);-minus 1 hour select date_sub (now (), interval 1 minute);-minus 1 minute select date_sub (now (), interval 1 second);-minus 1 second select date_sub (now (), interval 1 microsecond);-minus 1 millisecond select date_sub (now (), interval 1 week) -- minus 1 week select date_sub (now (), interval 1 month);-- minus 1 month select date_sub (now (), interval 1 quarter);-- minus 1 season select date_sub (now (), interval 1 year);-- minus 1 year after reading this article on how MySQL implements the date addition and subtraction function, if you think the article is well written, you can share it with more people.
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.