 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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 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)
Advertisements
 