- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 00:00 to today’s date
Let’s say the current date is 2019-09-14 8 :50 :10. Now, we want records from 00 :00 to 2019-09-14 8 :50 :10. Let us now see an example and create a table −
mysql> create table DemoTable ( DueDate datetime ); Query OK, 0 rows affected (0.66 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-09-14'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('2019-09-14 8 :00 :10'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('2019-09-14 8 :44 :00'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('2019-09-14 12 :10 :00'); 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 −
+---------------------+ | DueDate | +---------------------+ |2019-09-14 00:00 :00 | |2019-09-14 08 :00 :10| |2019-09-14 08 :44 :00| |2019-09-14 12 :10 :00| +---------------------+ 4 rows in set (0.00 sec)
Following is the query to select date from 00 :00 to today’s date −
mysql> select *from DemoTable where DueDate > DATE(NOW()) and DueDate < NOW();
This will produce the following output −
+---------------------+ | DueDate | +---------------------+ |2019-09-14 08 :00 :10| |2019-09-14 08 :44 :00| +---------------------+ 2 rows in set (0.00 sec)
- Related Articles
- How can I store ‘0000-00-00’ as a date in MySQL?
- MySQL query to order timestamp in descending order but place the timestamp 0000-00-00 00:00:00 first?
- In which format Year(2) or Year(4) MySQL will return the value of year from date ‘0000-00-00’?
- MySQL query to select date from timestamp?
- MySQL query to select closest date from today?
- MySQL query to select date >= current date - 3 weeks?
- Create MySQL datetime column with default 0000-00-00?
- MySQL query to select records with a particular date?
- MySQL Query to convert from datetime to date?
- How to select date from timestamp in MySQL?
- Select date from MySQL and format to text?
- MySQL date format DD/MM/YYYY select query?
- MySQL query to select records with a particular date and time?
- How to select only MySQL date from datetime column?
- MySQL query to fetch the latest date from a table with date records

Advertisements