[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-db
Subject:    Re: [PHP-DB] comparing stored timestamp with NOW()
From:       Nicholas Mercier <holyyakker () gmail ! com>
Date:       2009-02-24 23:11:50
Message-ID: 2725719a0902241511k7ad30ccaq161fc7df3aeb8bb7 () mail ! gmail ! com
[Download RAW message or body]

$days = 7;
$now = date(Y-m-d);
$timestamp = /*your defined stamp */;
$query = "SELECT * from TABLE WHERE DATEDIFF('$timestamp', '$now')<=7";

I think that is the query you want? Unless I'm misreading the manual -
which is entirely possible.

Conversely you can just use DATEDIFF('$timestamp', DATE())<=7 as well.
The only thing you need to make sre is that your $timestamp is in
YYYY-MM-DD format.

On Tue, Feb 24, 2009 at 4:35 PM, Terion Miller <webdev.terion@gmail.com> wrote:
> Hi I need help formatting a sql statement that compares my stored timestamp
> $stamp with NOW()
> what I'm trying to do is generate a SELECT statement that pulls only records
> within 7 days of NOW()
> should i use
>
>  *SELECT DATEDIFF('stamp','NOW()')=7d; not sure how the difference
> part is syntaxed*
>
> Thanks
> Terion
>
> Happy Freecycling
> Free the List !!
> www.freecycle.org
> Over Moderation of Freecycle List Prevents Post Timeliness.
> ------------------------------------------------
> Twitter?
> http://twitter.com/terionmiller
> ------------------------------------------------
> Facebook:
> <a href="http://www.facebook.com/people/Terion-Miller/1542024891"
> title="Terion Miller's Facebook profile" target=_TOP><img src="
> http://badge.facebook.com/badge/1542024891.237.919247960.png" border=0
> alt="Terion Miller's Facebook profile"></a>
> Vince Lombardi  - "Winning is habit. Unfortunately, so is losing."
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic