<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Get timestamp in milliseconds in Impala in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-timestamp-in-milliseconds-in-Impala/m-p/63361#M70148</link>
    <description>&lt;P&gt;How would you do this in reverse:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;given a unixtime value of&amp;nbsp;13949501310621, how would you convert to :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2014-03-16 00:08:51.621&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;?&lt;/P&gt;</description>
    <pubDate>Fri, 05 Jan 2018 21:51:56 GMT</pubDate>
    <dc:creator>chophouse</dc:creator>
    <dc:date>2018-01-05T21:51:56Z</dc:date>
    <item>
      <title>Get timestamp in milliseconds in Impala</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-timestamp-in-milliseconds-in-Impala/m-p/61214#M70146</link>
      <description>&lt;P&gt;I have a query wherein I need to extract timestamp with milliseconds to match data from Source. Below is sample data from SQL server (Source) and column is defined as Datetime&lt;/P&gt;&lt;P&gt;U_Date&lt;BR /&gt;2007-10-26&amp;nbsp;10:07:00.000&lt;BR /&gt;2005-05-04&amp;nbsp;11:12:54.297&lt;BR /&gt;2004-05-29 03:56:24.792&lt;/P&gt;&lt;P&gt;Target is Hadoop through Impala and defined as Timestamp&lt;/P&gt;&lt;P&gt;U_Date&lt;BR /&gt;2007-10-26&amp;nbsp;10:07:00&lt;BR /&gt;2005-05-04&amp;nbsp;11:12:54.297000000&lt;BR /&gt;2013-05-31&amp;nbsp;04:07:00&lt;BR /&gt;2013-11-01 15:34:00&lt;/P&gt;&lt;P&gt;I am looking for query to get timestamp as displayed in Source with millisecond. I have put together my query as under, but it defaults milliseconds to 000.&lt;/P&gt;&lt;P&gt;select from_unixtime(unix_timestamp(u_date),'yyyy-MM-dd HH:mm:ss.SSS') from table A&lt;/P&gt;&lt;P&gt;Generated result set is as below:&lt;/P&gt;&lt;P&gt;2007-10-26 10:07:00.000&lt;BR /&gt;2005-05-04 11:12:54.000 (Millisecond .297 defaulted to 000)&lt;BR /&gt;2013-05-31 04:07:00.000&lt;BR /&gt;2013-11-01 15:34:00.000&lt;/P&gt;&lt;P&gt;Kindly share your inputs&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 12:26:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-timestamp-in-milliseconds-in-Impala/m-p/61214#M70146</guid>
      <dc:creator>Manjuyell</dc:creator>
      <dc:date>2022-09-16T12:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Get timestamp in milliseconds in Impala</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-timestamp-in-milliseconds-in-Impala/m-p/61215#M70147</link>
      <description>&lt;P&gt;Hi Majuyell,&lt;/P&gt;&lt;P&gt;&amp;nbsp; I think the problem is your use of unix_timestamp(), which returns a value in seconds precision.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You probably want to convert directly to timestamp. It looks like your timestamps are in a regular format so you can probably cast directly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;gt; select cast("2005-05-04 11:12:54.297" as timestamp);
+----------------------------------------------+
| cast('2005-05-04 11:12:54.297' as timestamp) |
+----------------------------------------------+
| 2005-05-04 11:12:54.297000000                |
+----------------------------------------------+&lt;/PRE&gt;&lt;P&gt;Otherwise you can use to_timestamp() with a timestamp format string:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;gt; select to_timestamp("2005-05-04 11:12:54.297", "yyyy-MM-dd HH:mm:ss.SSS");
+--------------------------------------------------------------------+
| to_timestamp('2005-05-04 11:12:54.297', 'yyyy-mm-dd hh:mm:ss.sss') |
+--------------------------------------------------------------------+
| 2005-05-04 11:12:54.297000000                                      |
+--------------------------------------------------------------------+&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Then you can use from_timestamp to format it in your desired way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;gt; select from_timestamp(to_timestamp("2005-05-04 11:12:54.297", "yyyy-MM-dd HH:mm:ss.SSS"), "yyyy-MM-dd HH:mm:ss.SSS");

+---------------------------------------------------------------------------------------------------------------+
| from_timestamp(to_timestamp('2005-05-04 11:12:54.297', 'yyyy-mm-dd hh:mm:ss.sss'), 'yyyy-mm-dd hh:mm:ss.sss') |
+---------------------------------------------------------------------------------------------------------------+
| 2005-05-04 11:12:54.297                                                                                       |
+---------------------------------------------------------------------------------------------------------------+&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 18:38:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-timestamp-in-milliseconds-in-Impala/m-p/61215#M70147</guid>
      <dc:creator>Tim Armstrong</dc:creator>
      <dc:date>2017-10-24T18:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: Get timestamp in milliseconds in Impala</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-timestamp-in-milliseconds-in-Impala/m-p/63361#M70148</link>
      <description>&lt;P&gt;How would you do this in reverse:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;given a unixtime value of&amp;nbsp;13949501310621, how would you convert to :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2014-03-16 00:08:51.621&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 21:51:56 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-timestamp-in-milliseconds-in-Impala/m-p/63361#M70148</guid>
      <dc:creator>chophouse</dc:creator>
      <dc:date>2018-01-05T21:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Get timestamp in milliseconds in Impala</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-timestamp-in-milliseconds-in-Impala/m-p/63363#M70149</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/21358"&gt;@chophouse&lt;/a&gt;I wonder if the example I posted here would solve your problem: &lt;A href="http://community.cloudera.com/t5/Interactive-Short-cycle-SQL/Why-not-from-unixtime-function-handles-an-unix-timestamp-in/m-p/63182#M3969" target="_blank"&gt;http://community.cloudera.com/t5/Interactive-Short-cycle-SQL/Why-not-from-unixtime-function-handles-an-unix-timestamp-in/m-p/63182#M3969&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 22:47:03 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-timestamp-in-milliseconds-in-Impala/m-p/63363#M70149</guid>
      <dc:creator>Tim Armstrong</dc:creator>
      <dc:date>2018-01-05T22:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Get timestamp in milliseconds in Impala</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-timestamp-in-milliseconds-in-Impala/m-p/65396#M70150</link>
      <description>&lt;P&gt;Thanks Tim.&amp;nbsp; That works for my use case&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 22:06:46 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-timestamp-in-milliseconds-in-Impala/m-p/65396#M70150</guid>
      <dc:creator>chophouse</dc:creator>
      <dc:date>2018-03-14T22:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Get timestamp in milliseconds in Impala</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-timestamp-in-milliseconds-in-Impala/m-p/91620#M70151</link>
      <description>&lt;P&gt;how to do the same in unique way for all the columns, i mean inspite of providing numeric values what if i give the db.column_name ?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 09:06:52 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-timestamp-in-milliseconds-in-Impala/m-p/91620#M70151</guid>
      <dc:creator>Manan</dc:creator>
      <dc:date>2019-06-14T09:06:52Z</dc:date>
    </item>
  </channel>
</rss>

