MySQL Forums
Forum List  »  Newbie

Re: Datetime ranges
Posted by: Joao Prado Maia
Date: September 01, 2004 09:15AM

Hi,

You can use the DATE_SUB() function with the INTERVAL clause. From the manual:

http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html

----
Here is an example that uses date functions. The following query selects all records with a date_col value from within the last 30 days:

mysql> SELECT something FROM tbl_name
-> WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= date_col;
----

Hope that helps.

Cheers,
Joao Prado Maia
MySQL AB

Options: ReplyQuote


Subject
Written By
Posted
September 01, 2004 05:50AM
Re: Datetime ranges
September 01, 2004 09:15AM
September 02, 2004 12:26AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.