
- 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
How to select date from timestamp in MySQL?
To select date from timestamp in MySQL, you need to use DATE().
Let us first create a table −
mysql> create table DemoTable697( Id varchar(100), Title varchar(100), BatchTime timestamp ); Query OK, 0 rows affected (0.78 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable697 values('10','Java','2019-01-21 10:34:56'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable697 values('11','Spring','2019-03-11 11:14:16'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable697 values('12','Hibernate','2019-07-21 12:04:00'); Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable697;
This will produce the following output -
+------+-----------+---------------------+ | Id | Title | BatchTime | +------+-----------+---------------------+ | 10 | Java | 2019-01-21 10:34:56 | | 11 | Spring | 2019-03-11 11:14:16 | | 12 | Hibernate | 2019-07-21 12:04:00 | +------+-----------+---------------------+ 3 rows in set (0.00 sec)
Here is the query to select date from timestamp in MySQL −
mysql> select Title,DATE(BatchTime) AS OnlyDate from DemoTable697 where Id='10';
This will produce the following output -
+-------+------------+ | Title | OnlyDate | +-------+------------+ | Java | 2019-01-21 | +-------+------------+ 1 row in set (0.00 sec)
- Related Articles
- MySQL query to select date from timestamp?
- Select timestamp as date string in MySQL?
- Get timestamp date range with MySQL Select?
- Display only date from timestamp value in MySQL
- How to select only MySQL date from datetime column?
- MySQL query to select date from 00:00 to today’s date
- How to search for a date in MySQL timestamp field?
- MySQL query to select closest date from today?
- Select date from MySQL and format to text?
- How to Insert custom date into MySQL timestamp field?
- How to convert from Unix timestamp to MySQL timestamp value?
- How to select part of a Timestamp in a MySQL Query?
- Set current date and time to timestamp in MySQL
- How to select yesterday's date in MySQL?
- Convert MySQL Unix-Timestamp format to date format?

Advertisements