title: Get records where where timestamp is not today's date
body: <p>I have code as follows to get todays date:</p>
  
  <pre><code>today = str(date.today()) //2019-01-07
  </code></pre>
  
  <p>I want to get all records from the database where <code>timestamp</code> column is not as today. The function is as follows:</p>
  
  <pre><code>def get_vehicle_references():
    conn = db_connection()
    cur = conn.cursor()
    s = "SELECT reference, reference_url FROM vehicles v WHERE (NOT EXISTS (select reference from daily_run_vehicle rv WHERE (handled = %s or (handled = %s and retries &gt;= %s)) and DATE(rv.timestamp) &lt;&gt; %s AND reference = v.reference))"
    cur.execute(s, (True, False, 5, today))
    return cur.fetchall()
  </code></pre>
  
  <p>The timestamp column is in following format: <code>2019-01-07 11:10:18.491368</code></p>
  
  <p>I want to get all records from <code>vehicles</code> table where <code>timestamp</code> column in <code>daily_run_vehicle</code> table is not today.</p>
  
  <p>But this query gives me also records with todays date.</p>
  
  <p>Any idea?</p>
  
  <p>UPDATE:</p>
  
  <p>Thus I tried to cast it, and the query is as follows:</p>
  
  <pre><code>s = "SELECT reference, reference_url, timestamp FROM vehicles v WHERE (NOT EXISTS (select reference from daily_run_vehicle rv WHERE (handled = %s or (handled = %s and retries &gt;= %s)) AND rv.timestamp::date = %s AND reference = v.reference))"
  cur.execute(s, (True, False, 5, today))
  </code></pre>
  
  <p>But I still have the same problem.</p>