
- 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
Display Timestamp before the current date in MySQL
Let us first create a table −
mysql> create table DemoTable( ArrivalDate timestamp ); Query OK, 0 rows affected (1.96 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-09-14 17:25:00'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values('2019-09-13 17:25:00'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('2016-09-01 17:20:10'); Query OK, 1 row affected (0.38 sec) mysql> insert into DemoTable values('2019-09-11 12:00:00'); Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+---------------------+ | ArrivalDate | +---------------------+ | 2019-09-14 17:25:00 | | 2019-09-13 17:25:00 | | 2016-09-01 17:20:10 | | 2019-09-11 12:00:00 | +---------------------+ 4 rows in set (0.04 sec)
Following is the query to display timestamp before the current date −
mysql> select *from DemoTable where ArrivalDate < now();
This will produce the following output −
+---------------------+ | ArrivalDate | +---------------------+ | 2019-09-13 17:25:00 | | 2016-09-01 17:20:10 | | 2019-09-11 12:00:00 | +---------------------+ 3 rows in set (0.07 sec)
- Related Articles
- Display only date from timestamp value in MySQL
- Set current date and time to timestamp in MySQL
- Grab where current date and the day before with MySQL?
- Display all records ignoring the current date record in MySQL
- Get only the date in timestamp in MySQL?
- Fetch student records whose result declared 12 days before the current date in MYSQL
- Select timestamp as date string in MySQL?
- Display records from the current date till rest of the same month in MySQL?
- MySQL Select where timestamp is in the current hour?
- MySQL query to order and display difference between dates from the current date
- How to select date from timestamp in MySQL?
- Python Pandas - Get the current date and time from Timestamp object
- Get timestamp date range with MySQL Select?
- MySQL query to select date from timestamp?
- Select dates between current date and 3 months from the current date in MySQL?

Advertisements