Click to See Complete Forum and Search --> : MySQL query


Howlin Mad Murdock
05-07-2001, 01:17 PM
Hello,

I am working on writing a page with news content in it. I would like it to display the news from say the last month. So far my query look like this:

select * from news

Now I know I need to add the where part but I dont know how to manipulat the dates. I need something like:

select * from news where date= today - 31 days

How do I put this in Mysql code?

Thanks,

Murdock

Mikey123
05-07-2001, 03:44 PM
select * from news where date= today - 31 days


This is the example at mysql.com

SELECT * FROM news WHERE TO_DAYS(NOW()) - TO_DAYS(date) <= 31;
http://www.mysql.com/doc/D/a/Date_and_time_functions.html

f'lar
05-07-2001, 08:39 PM
WHERE date > today-31 days