Tutorialspoint

MySQL query to get current datetime and only current date


1 Answer
George John

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

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.