title: Adding 120 minutes if date diff is negative in Amazon Redshift
body: <p>I am grouping times how much it takes for a person to purchase an item, from the session time to purchase time. There are some cases when due to the timezones the purchase time is 120 minutes than it should be, in that case, I want to add 120 minutes and then group it like so:</p>
  <pre><code>CASE
      WHEN date_diff('minute'::character varying::text, sessions.event_time, sales.event_time) &lt; 0 AND sales.event_time IS NOT NULL THEN '0. 0'::character varying
      WHEN date_diff('minute'::character varying::text, sessions.event_time, sales.event_time) &lt;= 5 AND sales.event_time IS NOT NULL THEN '1. 0-5min'::character varying
      ELSE 'no sale'::character varying
  END AS grouped_session_to_sale, 
  </code></pre>
  <p>And because of the timezone difference of 2 hours I get a lot of <code>0.0</code> groups, I need to add 120 minutes to the <code>sales.event_time</code>, I tried this:</p>
  <pre><code>CASE
      WHEN date_diff('minute'::character varying::text, sessions.event_time, sales.event_time) &lt; 0 
      THEN sales.event_time::numeric+120::text
      ELSE sales.event_time
  END as sales.event_time,
  
  CASE
      WHEN date_diff('minute'::character varying::text, sessions.event_time, sales.event_time) &lt; 0 AND sales.event_time IS NOT NULL THEN '0. 0'::character varying
      WHEN date_diff('minute'::character varying::text, sessions.event_time, sales.event_time) &lt;= 5 AND sales.event_time IS NOT NULL THEN '1. 0-5min'::character varying
      ELSE 'no sale'::character varying
  END AS grouped_session_to_sale
  </code></pre>
  <p>But I get an error which is very uninformative:</p>
  <blockquote>
  <p>SQL Error [500310] [42601]: Amazon Invalid operation: syntax error at or near &quot;.&quot;
  Position: 3346;</p>
  </blockquote>
  <p>How can I achieve such a result?</p>