I want to find out how "fresh" an entry is, selecting only entries added 30 days from the current date.
I have a column called imagedate and the values are stored as datetime ( 0000-00-00 00:00:00 ). How could I write a query that will choose entries that are no older than 30 days?
Thanks for your help!
Use datetime to find age?
Moderator: General Moderators
Re: Use datetime to find age?
There are several ways to do this. You use date/time functions such as DATE_SUB() or subtract using math operators. I usually opt for the latter since it is easier to use indexes. Something like:
Code: Select all
WHERE imagedate > NOW() - INTERVAL 30 DAY Re: Use datetime to find age?
This worked perfectly. Thanks!