
- 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 current datetime and only current date
The query SELECT NOW() gives the current date as well as current time. If you want only current date, use only CURDATE(). Following is the syntax for datetime −
SELECT NOW();
The syntax for only date.
SELECT CURDATE();
Let us now implement the above syntax −
Case 1 : If you want both current date and time −
mysql> SELECT NOW();
Output
+-----------------------+ | NOW() | +-----------------------+ | 2019-06-02 15 :30 :39 | +-----------------------+ 1 row in set (0.00 sec)
Case 2 : If you want the current date only −
mysql> SELECT CURDATE();
Output
+------------+ | CURDATE() | +------------+ | 2019-06-02 | +------------+ 1 row in set (0.00 sec)
- Related Articles
- MySQL query to get the current date records wherein one of the columns displays current date
- Insert current date in datetime format MySQL?
- MySQL query to select date >= current date - 3 weeks?
- MySQL query to set current date in the datetime field for all the column values
- MySQL query to get the current date from the list of dates
- Filter query by current date in MySQL
- MySQL query to get only the minutes from datetime?
- Get only the date from datetime in MySQL?
- MySQL query to insert current date plus specific time?
- C# DateTime to add days to the current date
- How to get the difference between date records and the current date in MySQL?
- MySQL query to retrieve current date from a list of dates
- MySQL query to order and display difference between dates from the current date
- Get current time and date on Android
- MySQL Query to convert from datetime to date?

Advertisements