in reply to Get the date (MySQL style) for X days ago

perhaps i'm missing something, but you can do it in nothing but MySQL:

e.g. 2 days ago till today:

SELECT [anything you want] FROM [anywhere you want] WHERE [column storing date] >= current_date()-2;


(from http://mysql-tips.blogspot.com/2005/04/mysql-date-calculations.html )

Replies are listed 'Best First'.
Re^2: Get the date (MySQL style) for X days ago
by repeacock (Novice) on Oct 05, 2009 at 16:08 UTC
    Actually the current_date()-#days code doesn't work when it crosses a month boundary.

    Example: 20091005 - 7 = 20090998

    Try this instead SELECT DATE_SUB(CURDATE(),INTERVAL 7 DAY)