![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 seconds from all the date records in a MySQL column?
Let us first create a table −
mysql> create table DemoTable833(ArrivalTime datetime); Query OK, 0 rows affected (0.79 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable833 values('2019-01-10 12:40:50'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable833 values('2019-02-16 11:10:30'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable833 values('2018-03-17 10:00:10'); Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable833;
This will produce the following output −
+---------------------+ | ArrivalTime | +---------------------+ | 2019-01-10 12:40:50 | | 2019-02-16 11:10:30 | | 2018-03-17 10:00:10 | +---------------------+ 3 rows in set (0.00 sec)
Following is the query to subtract seconds from a MySQL date −
mysql> select ArrivalTime-interval 10 SECOND from DemoTable833;
This will produce the following output −
+--------------------------------+ | ArrivalTime-interval 10 SECOND | +--------------------------------+ | 2019-01-10 12:40:40 | | 2019-02-16 11:10:20 | | 2018-03-17 10:00:00 | +--------------------------------+ 3 rows in set (0.00 sec)
Advertisements