Get the current time: select current_timestamp; Output: 2016-06-16 16:12:52 select now(); Output: 2016-06-16 16:12:52 Get the minute before the current time: select SUBDATE(now(),interval 60 second); Output: 2016-06-16 16:11:52 Get the next minute from the current time: select ADDDATE(now(),interval 60 second); Output: 2016-06-16 16:13:52 By changing the units above. Can get the time before and after minutes, hours, days Get the time of the previous minute: select SUBDATE(now(),interval 1 minute); Output: 2016-06-16 16:16:38 Get the time of the previous hour: select SUBDATE(now(),interval 1 hour); Output: 2016-06-16 15:17:38 Get the time of the previous day: select SUBDATE(now(),interval 1 day); Output: 2016-06-15 16:17:38 Take the time after one minute: select ADDDATE(now(),interval 1 minute); Output: 2016-06-16 16:17:38 One hour after the pick-up: select ADDDATE(now(),interval 1 hour); Output: 2016-06-16 17:17:38 Time after the day of collection: select ADDDATE(now(),interval 1 day); Output: 2016-06-17 16:17:38 The following are supplements: mysql gets yesterday's date, today's date, tomorrow's date, and the time of the previous hour and the next hour 1. Current date select DATE_SUB(curdate(),INTERVAL 0 DAY); 2. Tomorrow's date select DATE_SUB(curdate(),INTERVAL -1 DAY); 3. Yesterday's date select DATE_SUB(curdate(),INTERVAL 1 DAY); 4. Last hour select date_sub(now(), interval 1 hour); 5. The next hour select date_sub(now(), interval -1 hour); 6. First 30 minutes select date_add(now(),interval -30 minute) 7. Last 30 minutes select date_add(now(),interval 30 minute) If you still can't find what you want, you can check out the related articles below. Thank you for your support of 123WORDPRESS.COM. You may also be interested in:
|
<<: Solve the problem of forgetting password in MySQL 5.7 under Linux
>>: React Hook usage examples (6 common hooks)
Table of contents 1. The simplest example 2. Cust...
Table of contents 1. Introduction to gojs 2. Gojs...
First, let's look at an example of memory rel...
In HTML, common URLs are represented in a variety ...
MySQL5.7.21 installation and password setting tut...
Background - Online Alert An online server issued...
Today, it suddenly occurred to me that it would be...
Automated project deployment is more commonly use...
<br />Previous Web Design Tutorial: Web Desi...
Table of contents The significance of standard co...
Table of contents question Server layer and stora...
Table of contents Achieve results Implementation ...
1. Natural layout <br />The layout without a...
1. Installation of Docker under CentOS8 curl http...
[LeetCode] 178.Rank Scores Write a SQL query to r...