title: Updating table column date with case expression?
body: <p>I need to update <code>column8</code> with data depending on two other columns with dates (<code>date1</code> and <code>date2</code>) - if <code>date1</code> is later than <code>date2</code> then <code>column8</code> is <code>YES</code> otherwise its <code>NO</code>.</p>
  
  <p>I wrote this:</p>
  
  <pre><code>update table1
  set delay = case when date1 &gt; date2 then 'YES' 
                   when date2 is NULL then 'YES' 
                   else 'NO'
              end
  </code></pre>
  
  <p>The problem is that it is probably not comparing the dates but length of the expression, because I have no in every column except for null columns... It tells me that it probably does not know I want it compare as a date But the columns in database are in date format <code>YYYY-MM-DD</code>.</p>
  
  <p>Is there any way to update my code or in adding something to make compare the dates and not the string lengths?</p>
  
  <p>Thanks!</p>