title: Hadoop Impala: Format datatype integer to date/timestamp to use addtime function
body: <p>I am working in Impala with the following table: </p>
  
  <pre><code>customer_id | day_id    | return_day_id
  ABC           20170830    20170923
  BCD           20170830    20170901
  </code></pre>
  
  <p>Unfortunately, both the day_id &amp; return_day_id fields are INT and not date. </p>
  
  <p>How can I change their datatype to be date, so that I can count distinct customer_ids only with return_day_id within 4 days after day_id. Would I need to cast it to date and then to timestamp so that I can use the adddate function? </p>