6 Replies Latest reply: Dec 12, 2016 8:19 PM by xxx yyy RSS

    Passing date variables to Postgres fails

    xxx yyy


      I'm trying to pass a date variable to a SQL query in postgres but no matter what conversion method I apply SQL sees the date as integer (e.g. 46801).



      LET vmaxdate = Date(lookup('maxdate', 'tableName', 'facttable' , 'historytable')) ,'D/MM/YYYY')  ;




      LOAD *;


      SELECT *

      FROM acc

      WHERE a.acc_date >=  $(vmaxdate );  <<<===


      postgresql reports error due to comparison between date and integer. I have tried all types of Date/Date#/Text, before WHERE clause but still qlik script passes the variable as integer to the SQL. (If I write this variable to a qvd I can make it show as D/MM/YYYY.).


      I also tried cast and to_date in SQL, to no avail.  Is there anyway to get around this ?