user979331
user979331

Reputation: 11961

SQL SELECT NOW()

Hey ya'll sorry for all the caps in the title, but its actually suppose to be like that.

I am running this in query

SELECT NOW()

and it returns this

2012-05-14 17:35:37

how do I remove the time, I only want the date.

Upvotes: 3

Views: 18104

Answers (8)

Agri A
Agri A

Reputation: 1

this might also work for mySQL:

Select CURDATE();

Upvotes: 0

Samuel Ramzan
Samuel Ramzan

Reputation: 1856

This woked for me like perdfect:

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

Upvotes: 1

Dev'Hamz
Dev'Hamz

Reputation: 488

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 |
+------------+

Upvotes: 0

avasin
avasin

Reputation: 9736

This MySQL select should return the date without the time.

SELECT CURRENT_DATE();

enjoy :)

Upvotes: 2

Mike
Mike

Reputation: 781

DATE(NOW())

is what I use - it just keeps the date portion

Upvotes: 0

Stefan Manciu
Stefan Manciu

Reputation: 500

I think this might also work

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

Upvotes: 2

Asaph
Asaph

Reputation: 162851

You could use the LEFT() function:

SELECT LEFT(NOW(), 10);

Here's a little demo:

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

Upvotes: 1

Adam V
Adam V

Reputation: 6356

How about CURDATE()?

SELECT CURDATE()

(Note: this is listed as MySQL in the webpage. Unsure what vendor/version of SQL you're running.)

Upvotes: 9

Related Questions