title: How do I get millisecond precision in hive?
body: <p>The <a href="https://cwiki.apache.org/Hive/languagemanual-types.html#LanguageManualTypes-Timestamps" rel="nofollow" title="LanguageManual">documentation</a> says that timestamps support the following conversion:</p>
  
  <p>•Floating point numeric types: Interpreted as UNIX timestamp in seconds with decimal precision</p>
  
  <p>First of all, I'm not sure how to interpret this. If I have a timestamp 2013-01-01 12:00:00.423, can I convert this to a numeric type that retains the milliseconds? Because that is what I want.</p>
  
  <p>More generally, I need to do comparisons between timestamps such as</p>
  
  <pre><code>select maxts - mints as latency from mytable
  </code></pre>
  
  <p>where <em>maxts</em> and <em>mints</em> are timestamp columns. Currently, this gives me <code>NullPointerException</code> using Hive 0.11.0. I am able to perform queries if I do something like</p>
  
  <pre><code>select unix_timestamp(maxts) - unix_timestamp(mints) as latency from mytable
  </code></pre>
  
  <p>but this only works for seconds, not millisecond precision.</p>
  
  <p>Any help appreciated. Tell me if you need additional information.</p>