tags:

views:

23

answers:

1

Quite a simple question, but I haven't been able to find any useful resources to help with this.

Basically, I want to query my SQL database table, of which one of the fields is of type 'date'. Currently, the webpage outputs the three most recent records dependent on this date field. Ideally, I want to display all records which are under 4 months old, but I'm not sure how to go about implementing this in my query.

Can anyone advise?

+2  A: 
SELECT * FROM table WHERE datecolumn > DATE_SUB(NOW(), INTERVAL 4 MONTH)

Will select all rows where the date is larger than 4 months ago (assuming you have no dates in the future - else you could use a BETWEEN)

Konerak