1

I have a table with a column name "ordered_at" where I have entered the value of time(). How can I select records from the last 30 days?

Mureinik
  • 277,661
  • 50
  • 283
  • 320
yikemop651
  • 85
  • 1
  • 7

1 Answers1

0

You could use datediff to get the number of days passed between current_date and the value in the column:

SELECT *
FROM   mytable
WHERE  DATEDIFF(CURRENT_DATE, ordered_at) <= 30
Mureinik
  • 277,661
  • 50
  • 283
  • 320