Number of days between current date and date field

You can use this for accurate result

SELECT DATEDIFF(CURDATE(), DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(`date`)), '%Y-%m-%d')) AS days FROM `table1`

Your DATE field should have DATE or DATETIME format to be used as DATEDIFF argument correctly.

Also DATE is MySQL keyword and I am not sure that you can use it as valid field name.


You can use STR_TO_DATE():

SELECT DATEDIFF(CURDATE(),STR_TO_DATE(date, '%m/%d/%Y')) AS days
FROM table1

SQLFiddle Demo

Tags:

Datediff

Mysql