title: Get the sysdate -1 in Hive
body: <p>Is there any way to get the <code>current date -1</code> in Hive means <code>yesterdays date</code> always?
  And in this format- <code>20120805</code>?</p>
  
  <p>I can run my query like this to get the data for <code>yesterday's date</code> as today is <code>Aug 6th</code>-</p>
  
  <pre><code>select * from table1 where dt = '20120805';
  </code></pre>
  
  <p>But when I tried doing this way with <code>date_sub function</code> to get the yesterday's date as the below table is partitioned on date(dt) column.</p>
  
  <pre><code>select * from table1 where dt = date_sub(TO_DATE(FROM_UNIXTIME(UNIX_TIMESTAMP(),
  'yyyyMMdd')) , 1)     limit 10;
  </code></pre>
  
  <p>It is looking for the data in all the partitions? Why? Something wrong I am doing in my query?</p>
  
  <p><strong>How I can make the evaluation happen in a subquery to avoid the whole table scanned?</strong></p>