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
  • 11,296
  • 3
  • 28
  • 47
user979331
  • 11,039
  • 73
  • 223
  • 418
  • 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,256
  • 3
  • 40
  • 52
2

This MySQL select should return the date without the time.

SELECT CURRENT_DATE();

enjoy :)

octopusgrabbus
  • 10,555
  • 15
  • 68
  • 131
avasin
  • 9,186
  • 18
  • 80
  • 127
2

I think this might also work

SELECT CONVERT(VARCHAR(10),GETDATE(),111)
Stefan Manciu
  • 490
  • 1
  • 6
  • 19
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
  • 159,146
  • 25
  • 197
  • 199
1

This woked for me like perdfect:

SELECT * FROM table WHERE DATE(myDate) = DATE(NOW())
Samuel Ramzan
  • 1,770
  • 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
  • 478
  • 4
  • 9