$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()
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
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