
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Fetch Rows Updated at Timestamp Older Than 1 Day in MySQL
For this,yYou can use from_unixtime() along with now().
Let us create a table with some data type −
Example
mysql> create table demo75 -> ( -> due_date int(11) -> ); Query OK, 0 rows affected, 1 warning (2.87
Insert some records into the table with the help of insert command −
Example
mysql> insert into demo75 values(unix_timestamp("2020-01-10")); Query OK, 1 row affected (0.46 mysql> insert into demo75 values(unix_timestamp("2020-11-19")); Query OK, 1 row affected (0.59 mysql> insert into demo75 values(unix_timestamp("2020-12-18")); Query OK, 1 row affected (0.44 mysql> insert into demo75 values(unix_timestamp("2020-11-10")); Query OK, 1 row affected (0.70
Display records from the table using select statement −
Example
mysql> select *from demo75;
This will produce the following output −
Output
+------------+
| due_date |
+------------+
| 1578594600 || 1605724200 |
| 1608229800 || 1604946600 |
+------------+4 rows in set (0.00 sec)
Following is the query to fetch rows updated at a timestamp older than 1 day in MySQL −
Example
mysql> select * from demo75 -> where from_unixtime(due_date) < now() - interval 1 day;
This will produce the following output −
Output
+------------+
| due_date |+------------+
| 1578594600 || 1604946600 |
+------------+
2 rows in set (0.00 sec)
Advertisements