Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Chris Styles
May 12, 2006, 6:14 pm
rate this thread
I'm learning MySQL, and I am struggling with a few odds and ends. The one
that I can't see how to crack is to search by age.
The records in my database have a datetime field for when they were
In my web front end I want to do a "show me entries inserted during the last
[1-9] Days or [1-3] months"
I am guessing the query will be something like
Select * where Date > NOW () - <some number of days or months>
My PHP script can take account for if it is filtering in days or months, but
I cant work out the actual syntax for subtracting a set number of days or
months from NOW()
Any help gratefully accepted!
Re: Newbie question
SELECT * FROM `tablename` WHERE `datecol` > NOW() - INTERVAL 9 DAY
SELECT * FROM `tablename` WHERE `datecol` > DATE_SUB(NOW(), INTERVAL 9 DAY)
- » Americanas.com SALDO de TVs Com at 80% de Desconto (29798)
- — Newest thread in » MySQL Database Forum