title: PostgreSQL refuses to update DATE column
body: <p>I have a table that contains one value, <code>period_start TIMESTAMP NOT NULL</code>. I'd like to have a second column that stores the day of that timestamp.</p>
  
  <p>I tried the following sql:</p>
  
  <pre><code>ALTER TABLE foo ADD COLUMN day DATE;
  
  UPDATE foo SET day = period_start::DATE;
  
  ALTER TABLE foo ALTER COLUMN day SET NOT NULL;
  </code></pre>
  
  <p>Now, when I execute the above, I get an error that <code>day</code> contains null values. Looking at the content of the table, I see that every row has <code>NULL</code> as the value of day.</p>
  
  <p>However, <code>SELECT *, period_start::DATE FROM foo</code> gives me the expected result.</p>
  
  <p><strong>Why does my <code>UPDATE</code> statement fail and how can I fix it so that the <code>day</code> column gets correctly populated?</strong></p>