Drupal 7: can't get SQL query to work that works outside of Drupal
Instead of the above one try the following query,

$date = date_create();
date_modify($date, '-4 week');
$interval =  $date-&gt;format('U');

$result = db_query("
SELECT timestamp 
FROM accesslog
WHERE uid = :uid 
AND path = :path
AND timestamp &gt; :interval",
array(':uid'=&gt;$uid,
      ':path'=&gt;$path,
      ':interval'=&gt;$interval))-&gt;fetchAll();