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
  • 40,041
  • 8
  • 39
  • 58
WeekendCoder
  • 791
  • 3
  • 10
  • 15

2 Answers2

1

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

Fabian Winkler
  • 1,321
  • 15
  • 23
0

You can use the DATEDIFF() function

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

DATEDIFF parameters explained:

DATEDIFF(date1,date2)