This topic is locked

SQL query to show last 7 days only

4/17/2008 6:24:48 AM
PHPRunner General questions
L
Lisa2006 author

Hi All,
Need a little help with the following:
I only want to display records that have been added in the last 7 days from the current date.
select `companyname`,

`firstname`,

`surname`,

`dateposted`,

`address`

From `journey`
Field: dateposted is the date set when the record is added.
Thanks in advance
Lisa

J
Jane 4/17/2008

Hi,
use MySQL datediff() function for that.

Here is a sample:

select ... from ... where DateDiff(now(), DateField)<7


More info:

http://dev.mysql.com/doc/refman/5.0/en/dat...nction_datediff