Look directly for the database time functions.
For mysql:
Code:
Here is an example that uses date functions. The following query
selects all rows 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;