
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Fetching 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)
- Related Articles
- Delete records where timestamp older than 5 minutes in MySQL?
- Deleting all rows older than 5 days in MySQL
- How to delete rows older than 14 days in MySQL?
- Selecting rows that are older than current date in MySQL?
- MySQL query to select rows older than a week?
- MySQL query to delete all rows older than 30 days?
- Fetching rows added in last hour with MySQL?
- MySQL query to return all records with a datetime older than 1 week
- How to get day name from timestamp in MySQL?
- How to select rows in MySQL that are >= 1 DAY from the current date?
- Extract the Day / Month / Year from a Timestamp in PHP MySQL?
- When running UPDATE … datetime = NOW(); will all rows updated have the same date/ time in mysql?
- Fetching multiple MySQL rows based on a specific input within one of the table columns?
- MySQL's now() +1 day?
- MySQL query to delete a DATE older than 30 days from another date?

Advertisements