
- 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 only date from timestamp value in MySQL
To display the only date from timestamp value, use the FROM_UNIXTIME() method in MySQL. Let us first create a table −
mysql> create table DemoTable -> ( -> timestampValue bigint -> ); Query OK, 0 rows affected (0.70 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(1538332200); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(1577730600); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(1488652200); Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----------------+ | timestampValue | +----------------+ | 1538332200 | | 1577730600 | | 1488652200 | +----------------+ 3 rows in set (0.00 sec)
Following is the query to display date from timestamp value −
mysql> select from_unixtime(timestampValue) as Date from DemoTable;
This will produce the following output −
+---------------------+ | Date | +---------------------+ | 2018-10-01 00:00:00 | | 2019-12-31 00:00:00 | | 2017-03-05 00:00:00 | +---------------------+ 3 rows in set (0.00 sec)
- Related Articles
- Get only the date in timestamp in MySQL?
- Display Timestamp before the current date in MySQL
- How to select date from timestamp in MySQL?
- Convert DATE timestamp to return only the month name in MySQL
- MySQL query to select date from timestamp?
- Get first date from timestamp in MySQL group by another column with duplicate value
- How to display only 200 characters from total value in MySQL?
- Display matching repeated date records only once in MySQL
- How to convert from Unix timestamp to MySQL timestamp value?
- Get only the date from datetime in MySQL?
- Select timestamp as date string in MySQL?
- Extract Numeric Date Value from Date Format in MySQL?
- Get timestamp date range with MySQL Select?
- How to select only MySQL date from datetime column?
- Set current date and time to timestamp in MySQL

Advertisements