![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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