title: Convert UTC based on a separate time zone column - Postgres
body: <p>I have a table which has:</p>
  
  <ul>
  <li>Source date column</li>
  <li>Source timestamp (30 minute interval, a string)</li>
  <li>The datetime UTC timestamptz column</li>
  <li><p>The 'reporting' time zone (how the time zone should be displayed eventually)</p>
  
  <pre><code>date      interval     datetime_utc     time_zone
  </code></pre>
  
  <p>2018-05-11    22:30     2018-05-10 03:30:00  America/New_York</p></li>
  </ul>
  
  <p>Is there an efficient way to convert the datetime_utc column to the time zone indicated in the same row within a query or a view? I was able to do this using Python, but I would like to know how to do it directly in my query. </p>
  
  <p>This seems to work - I am able to refer to the column name and it converts it accurately based on the value found in that row.</p>
  
  <pre><code> (interval_timestamp_utc :: TIMESTAMPTZ AT TIME ZONE time_zone) :: DATE AS "Reporting Date",
  
   to_char((interval_timestamp_utc :: TIMESTAMPTZ AT TIME ZONE time_zone), 'HH24:MI') AS "Reporting Interval",
  </code></pre>