Re: Datetime within past week
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Sun, 19 Nov 2006 18:05:37 -0500
Greg Scharlemann wrote:
I have a series of records in a database. When each record is stored,
the datetime is logged: $date = date("Y-m-d H:i:s");
Prior to adding a new record to the database, I want to run a query to
retrieve all of the records uploaded in the last 7 days. I thought it
would be easiest to:
Pseudo Code:
$newDate = $date - 7 days;
select * from TABLE where DATE > $newDate;
Problem is I can't figure out how to subtract 7 days from $date and
convert that value to a valid datetime object.
Thanks for any help
If it's MySQL, you can do it all in SQL:
$result = mysql_query('SELECT myColumn FROM myTable where datacol= SUBDATE(NOW(), INTERVAL 7 DAY))';
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.
- References:
- Datetime within past week
- From: Greg Scharlemann
- Datetime within past week
- Prev by Date: Re: Datetime within past week
- Next by Date: Re: Display errors off problem?
- Previous by thread: Re: Datetime within past week
- Next by thread: Re: ok i decided to take Erwin Moller and start a fresh topic and im taking a different approach
- Index(es):
Relevant Pages
|