title: ERROR: invalid input syntax for type timestamp with time zone
body: <p>I have a PostgreSQL query as below which is running fine . I am calling it from a shell script as below</p>
  
  <pre><code>Result=$(psql -U username -d database -t -c 
  $'SELECT round(sum(i.total), 2) AS "ROUND(sum(i.total), 2)" 
    FROM invoice i 
    WHERE i.create_datetime = '2019-03-01 00:00:00-06' 
    AND i.is_review = '1' AND i.user_id != 60;')
  </code></pre>
  
  <p>now I want the value which I have hard coded as <code>i.create_datetime = '2019-03-01 00:00:00-06'</code> to replace it with a variable date value.</p>
  
  <p>I have tried two ways </p>
  
  <p>way 1:</p>
  
  <pre><code>Result=$(psql -U username -d database -t -c 
  $'WITH var(reviewMonth) as (values(\'$reviewMonth\')) 
  SELECT round(sum(i.total),2) AS "ROUND(sum(i.total),2)" 
  FROM var,invoice i 
  WHERE i.create_datetime = var.reviewMonth::timestamp 
  AND i.is_review = \'1\' AND i.user_id != 60;')
  </code></pre>
  
  <p>and </p>
  
  <p>way 2:</p>
  
  <pre><code>Result=$(psql -U username -d database -t -c 
  $'SELECT round(sum(i.total),2) AS "ROUND(sum(i.total),2)" 
  FROM invoice i 
  WHERE i.create_datetime = \'$reviewMonth\' 
  AND i.is_review = \'1\' AND i.user_id != 60;')
  </code></pre>
  
  <p>But both way it's throwing error</p>
  
  <p>way 1 throwing error as :</p>
  
  <blockquote>
    <p>ERROR:  operator does not exist: timestamp with time zone = text</p>
  </blockquote>
  
  <p>way 2 throwing error as :</p>
  
  <blockquote>
    <p>ERROR:  invalid input syntax for type timestamp with time zone: "$reviewMonth"</p>
  </blockquote>
  
  <p>Please suggest what should be my approach.</p>