

- 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 retrieve current date from a list of dates
Let’s say the current date is −
2019-07-22
Let us first create a table −
mysql> create table DemoTable705 (ShippingDate datetime); Query OK, 0 rows affected (0.67 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable705 values('2019-01-21 23:59:00'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable705 values('2019-07-22 00:00:30'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable705 values('2019-07-21 12:01:30'); Query OK, 1 row affected (0.44 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable705;
This will produce the following output -
+---------------------+ | ShippingDate | +---------------------+ | 2019-01-21 23:59:00 | | 2019-07-22 00:00:30 | | 2019-07-21 12:01:30 | +---------------------+ 3 rows in set (0.00 sec)
Following is the query to retrieve current date from a list of dates −
mysql> select *from DemoTable705 where date(ShippingDate)=CURDATE();
This will produce the following output -
+---------------------+ | ShippingDate | +---------------------+ | 2019-07-22 00:00:30 | +---------------------+ 1 row in set (0.00 sec)
- Related Questions & Answers
- MySQL query to get the current date from the list of dates
- MySQL query to order and display difference between dates from the current date
- Select dates between current date and 3 months from the current date in MySQL?
- Get maximum date from a list of varchar dates in MySQL
- MySQL query to retrieve records from the part of a comma-separated list?
- MySQL time period query to fetch date records from interval of 14 weeks from current date?
- Retrieve MIN and MAX date in a single MySQL query from a column with date values
- MySQL query to get current datetime and only current date
- MySQL query to select date >= current date - 3 weeks?
- Filter query by current date in MySQL
- MySQL query to get the current date records wherein one of the columns displays current date
- MySQL query to insert current date plus specific time?
- Comparison of varchar date records from the current date in MySQL
- MySQL query to select date from timestamp?
- MySQL Query to convert from datetime to date?
Advertisements