3

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.

BenR
  • 10,308
  • 3
  • 26
  • 45
user979331
  • 9,373
  • 64
  • 206
  • 383
  • 1
    possible duplicate of [How to return the date part only from a SQL Server datetime datatype](http://stackoverflow.com/questions/113045/how-to-return-the-date-part-only-from-a-sql-server-datetime-datatype) – mellamokb May 14 '12 at 21:39
  • We shouldnt have to answer this question, its basic mysql and can be found in the manual. https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html – Grumpy May 06 '22 at 09:08

7 Answers7

9

How about CURDATE()?

SELECT CURDATE()

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

Adam V
  • 6,068
  • 3
  • 38
  • 51
2

This MySQL select should return the date without the time.

SELECT CURRENT_DATE();

enjoy :)

octopusgrabbus
  • 10,250
  • 13
  • 64
  • 126
avasin
  • 8,306
  • 14
  • 74
  • 120
2

I think this might also work

SELECT CONVERT(VARCHAR(10),GETDATE(),111)
Stefan Manciu
  • 500
  • 1
  • 5
  • 18
1

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)
Asaph
  • 154,284
  • 25
  • 189
  • 193
1

This woked for me like perdfect:

SELECT * FROM table WHERE DATE(myDate) = DATE(NOW())
Samuel Ramzan
  • 1,660
  • 1
  • 15
  • 24
0
DATE(NOW())

is what I use - it just keeps the date portion

Mike
  • 751
  • 2
  • 7
  • 14
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 |
+------------+
Dev'Hamz
  • 438
  • 4
  • 9