SQL SELECT NOW ()

Hey, I apologize for all the caps in the title, but actually it should be.

I run this in the request

SELECT NOW()

and he returns it

2012-05-14 17:35:37

how to remove time, i want only date.

+3
source share
7 answers

How about CURDATE () ?

SELECT CURDATE()

(Note: this is indicated as MySQL on the web page. You do not know which SQL provider / version you are using.)

+8
source

This MySQL choice should return a date without time.

SELECT CURRENT_DATE();

enjoy :)

+2
source

,

SELECT CONVERT(VARCHAR(10),GETDATE(),111)
+2

LEFT():

SELECT LEFT(NOW(), 10);

:

mysql> SELECT LEFT(NOW(), 10);
+-----------------+
| LEFT(NOW(), 10) |
+-----------------+
| 2012-05-14      |
+-----------------+
1 row in set (0.00 sec)
+1

perdfect:

SELECT * FROM table WHERE DATE(myDate) = DATE(NOW())
+1
DATE(NOW())

- , -

0

You can also create a date format and use NOW().

| date_int | date         | YES  |     | NULL    |       |
+----------+--------------+------+-----+---------+-------+
mysql> UPDATE borderaux SET date_int = NOW();

+------------+
| date_int   |
+------------+
| 2013-07-15 |
+------------+
0
source

All Articles