Compare date to today's date and return number of days

datetime, mysql, sql

Solution

I think we need more information from your side, like the query you are using and what you tried so far, but maybe this can help you out:

SELECT 
    DATEDIFF('2014-02-20 00:00:00', NOW()); //return 7

In this case, you should add a 'FROM table' and replace the date in this query to the `datetime` column. Something like this:

SELECT 
    DATEDIFF(datetimefield, NOW())
FROM
    tablename

Problem

I am using MySQL. I am trying to compare a date that is in a datetime field to today's date and return the number of days difference [i.e. today - column = no. of days] Is that possible? How would I do it?

Original source