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
  • 297,002
  • 52
  • 306
  • 350
yikemop651
  • 125
  • 1
  • 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
  • 297,002
  • 52
  • 306
  • 350