Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
How to subtract 10 days from the current datetime in MySQL?
Firstly, let us get the current datetime with the help of the now() function.
mysql> select now();
The following is the output.
+---------------------+ | now() | +---------------------+ | 2018-11-01 19:55:56 | +---------------------+ 1 row in set (0.00 sec)
Syntax to subtract 10 days with the help of DATE_SUB()
select DATE_SUB(now(),interval integer_value day );
Applying the above syntax to subtract 10 days from the current datetime.
mysql> select DATE_SUB(now(),interval 10 day);
Here is the output.
+---------------------------------+ | DATE_SUB(now(),interval 10 day) | +---------------------------------+ | 2018-10-22 19:56:07 | +---------------------------------+ 1 row in set (0.00 sec)
Advertisements
