Re: [PHP-DB] comparing stored timestamp with NOW()

2009-02-24 Thread Nicholas Mercier
$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()

Re: [PHP-DB] comparing stored timestamp with NOW()

2009-02-24 Thread Andrés G . Montañez
If your timestamps is an UNIX Timestamp, and your DB is MySQL, this should do the trick $days = 7; $sql = 'SELECT (UNIX_TIMESTAMP() - ' . $timeStamp . ') <= (3600*24*' . $days . ');'; 3600*24 is one day in seconds, so multiply it by the days limit (7 days). Example Query: mysql> SELECT (UNIX_TIM

[PHP-DB] comparing stored timestamp with NOW()

2009-02-24 Thread Terion Miller
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* Thank