
- 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
MySQL query to get the current date records wherein one of the columns displays current date
To achieve this, following is the syntax wherein we have used DATE(NOW()) −
select *from yourTableName where DATE(yourColumnName)=DATE(NOW());
Let us first create a table −
mysql> create table DemoTable706 ( UserId varchar(100), UserName varchar(100), UserSignupDate datetime ); Query OK, 0 rows affected (0.57 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable706 values('John1@gmail.com','John','2019-01-31 12:45:22'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable706 values('Chris123@gmail.com','Chris','2019-07-22 10:05:02'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable706 values('12Robert@gmail.com','Robert','2019-06-22 11:25:22'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable706 values('DavidM@gmail.com','David','2019-07-22 00:00:02'); Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable706;
This will produce the following output -
+--------------------+----------+---------------------+ | UserId | UserName | UserSignupDate | +--------------------+----------+---------------------+ | John1@gmail.com | John | 2019-01-31 12:45:22 | | Chris123@gmail.com | Chris | 2019-07-22 10:05:02 | | 12Robert@gmail.com | Robert | 2019-06-22 11:25:22 | | DavidM@gmail.com | David | 2019-07-22 00:00:02 | +--------------------+----------+---------------------+ 4 rows in set (0.00 sec)
Following is the query to get records wherein one of the columns displays current date −
mysql> select *from DemoTable706 where DATE(UserSignupDate)=DATE(NOW());
This will produce the following output -
+--------------------+----------+---------------------+ | UserId | UserName | UserSignupDate | +--------------------+----------+---------------------+ | Chris123@gmail.com | Chris | 2019-07-22 10:05:02 | | DavidM@gmail.com | David | 2019-07-22 00:00:02 | +--------------------+----------+---------------------+ 2 rows in set (0.00 sec)
- Related Articles
- MySQL query to find the date records wherein the current date and time is in between the JoiningDate and RelievingDate
- MySQL query to get current datetime and only current date
- How to get the difference between date records and the current date in MySQL?
- MySQL query to get the current date from the list of dates
- Comparison of varchar date records from the current date in MySQL
- MySQL query to fetch date records greater than the current date after adding days with INTERVAL?
- MySQL query to select date >= current date - 3 weeks?
- MySQL time period query to fetch date records from interval of 14 weeks from current date?
- How to get the records of the last two days from the current date in MySQL?
- Find the difference between current date and the date records from a MySQL table
- Filter query by current date in MySQL
- Display all records ignoring the current date record in MySQL
- MySQL query to insert current date plus specific time?
- Calling NOW() function to fetch current date records in MySQL?
- Condition to check for due date and current date records in MySQL where clause

Advertisements