0

I have a DATETIME column in my table and I would like to know the number of days between the DATETIME value and now.

The query must be something like this:

SELECT *, DATESUBWHATEVER(datetimefield) AS days FROM table
jarlh
  • 42,561
  • 8
  • 45
  • 63
WeekendCoder
  • 915
  • 3
  • 11
  • 15

2 Answers2

1

SELECT TIMESTAMPDIFF(DAY, datetimefield, NOW()) AS days from table;

Fabian Winkler
  • 1,401
  • 16
  • 24
0

You can use the DATEDIFF() function

SELECT *, DATEDIFF(DateTimeField,NOW()) FROM TABLE

DATEDIFF parameters explained:

DATEDIFF(date1,date2)