By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,959 Members | 1,136 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,959 IT Pros & Developers. It's quick & easy.

mysql query to get rec's created in last 30 days

P: n/a
can you write a mysql qery to retrieve all rows from a table where the
date collumn is equal to a value (date) from now to 30 days ago?

Jun 22 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Thu, 22 Jun 2006 03:03:29 -0700, monomaniac21 wrote:
can you write a mysql qery to retrieve all rows from a table where the
date collumn is equal to a value (date) from now to 30 days ago?


SELECT *
FROM my_table
WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= my_date_column;

http://dev.mysql.com/doc/refman/5.0/...functions.html

Cheers,
Andy

--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

Jun 22 '06 #2

P: n/a

monomaniac21 wrote:
can you write a mysql qery to retrieve all rows from a table where the
date collumn is equal to a value (date) from now to 30 days ago?


Do you really mean 30 days ago or do you want 1 month ago instead?

Jun 23 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.