In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will bring you an article that introduces the MySQL date addition and subtraction function. The editor thinks it is very practical, so I will share it for you as a reference. Let's follow the editor and have a look.
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 quarter select date_sub (now (), interval 1 year);-- minus 1 year
On the MySQL date addition and subtraction function to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you like this article, you might as well share it for more people to see.
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: 237
*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.