

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
MySQL query to select date from timestamp?
Let us first create a table. One of the column is a timestamp −
mysql> create table DemoTable -> ( -> CustomerName varchar(100), -> CustomerShippingDate timestamp -> ); Query OK, 0 rows affected (0.52 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Chris','2019-01-21'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('David','2019-03-01'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values('Robert','2019-06-04'); Query OK, 1 row affected (0.25 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
This will produce the following output −
+--------------+----------------------+ | CustomerName | CustomerShippingDate | +--------------+----------------------+ | Chris | 2019-01-21 00:00:00 | | David | 2019-03-01 00:00:00 | | Robert | 2019-06-04 00:00:00 | +--------------+----------------------+ 3 rows in set (0.00 sec)
Following is the query to select date on timestamp −
mysql> select *,date(CustomerShippingDate) from DemoTable;
Output
This will produce the following output −
+--------------+----------------------+----------------------------+ | CustomerName | CustomerShippingDate | date(CustomerShippingDate) | +--------------+----------------------+----------------------------+ | Chris | 2019-01-21 00:00:00 | 2019-01-21 | | David | 2019-03-01 00:00:00 | 2019-03-01 | | Robert | 2019-06-04 00:00:00 | 2019-06-04 | +--------------+----------------------+----------------------------+ 3 rows in set (0.00 sec)
- Related Questions & Answers
- How to select date from timestamp in MySQL?
- MySQL query to select closest date from today?
- Get timestamp date range with MySQL Select?
- Select timestamp as date string in MySQL?
- MySQL query to select date from 00:00 to today’s date
- MySQL query to select date >= current date - 3 weeks?
- How to select part of a Timestamp in a MySQL Query?
- Display only date from timestamp value in MySQL
- MySQL query to select records with a particular date?
- MySQL date format DD/MM/YYYY select query?
- Select date from MySQL and format to text?
- MySQL Query to convert from datetime to date?
- MySQL query to convert timestamp to month?
- Format date in MySQL SELECT * query uisng FORMATDATE() method?
- How to select only MySQL date from datetime column?
Advertisements