<?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 from_unixtime format with literal H in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/from-unixtime-format-with-literal-H/m-p/53638#M59423</link>
    <description>&lt;P&gt;I would like to use from_unixtime to convert a unix_timestamp to a string in the format 2017-04-13H08 where the 08 is the hour of day. &amp;nbsp;I haven't figured out how I can do that. &amp;nbsp;I've tried several approaches with backslashes and quotes without success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example that would produce 2017-04-13T08.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[i-pvd1c1mgr-vip.vldb-bo.secureworkslab.com:21001] &amp;gt; select from_unixtime(unix_timestamp('2017-04-13 08:10:11'),'yyyy-MM-ddTHH');&lt;BR /&gt;Query: select from_unixtime(unix_timestamp('2017-04-13 08:10:11'),'yyyy-MM-ddTHH')&lt;BR /&gt;+-----------------------------------------------------------------------+&lt;BR /&gt;| from_unixtime(unix_timestamp('2017-04-13 08:10:11'), 'yyyy-mm-ddthh') |&lt;BR /&gt;+-----------------------------------------------------------------------+&lt;BR /&gt;| 2017-04-13T08 |&lt;BR /&gt;+-----------------------------------------------------------------------+&lt;BR /&gt;Fetched 1 row(s) in 0.01s&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are some of my attempts:&lt;/P&gt;&lt;P&gt;[i-pvd1c1mgr-vip.vldb-bo.secureworkslab.com:21001] &amp;gt; select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-ddHHH');&lt;BR /&gt;Query: select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-ddHHH')&lt;BR /&gt;+-----------------------------------------------------------------------+&lt;BR /&gt;| from_unixtime(unix_timestamp('2017-04-08 09:10:11'), 'yyyy-mm-ddhhh') |&lt;BR /&gt;+-----------------------------------------------------------------------+&lt;BR /&gt;| 2017-04-08009 |&lt;BR /&gt;+-----------------------------------------------------------------------+&lt;BR /&gt;Fetched 1 row(s) in 0.02s&lt;BR /&gt;[i-pvd1c1mgr-vip.vldb-bo.secureworkslab.com:21001] &amp;gt; select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd\\HHH');&lt;BR /&gt;Query: select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd\\HHH')&lt;BR /&gt;+-------------------------------------------------------------------------+&lt;BR /&gt;| from_unixtime(unix_timestamp('2017-04-08 09:10:11'), 'yyyy-mm-dd\\hhh') |&lt;BR /&gt;+-------------------------------------------------------------------------+&lt;BR /&gt;| 2017-04-08\009 |&lt;BR /&gt;+-------------------------------------------------------------------------+&lt;BR /&gt;Fetched 1 row(s) in 0.01s&lt;BR /&gt;[i-pvd1c1mgr-vip.vldb-bo.secureworkslab.com:21001] &amp;gt; select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd\'H\'HH');&lt;BR /&gt;Query: select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd\'H\'HH')&lt;BR /&gt;+---------------------------------------------------------------------------+&lt;BR /&gt;| from_unixtime(unix_timestamp('2017-04-08 09:10:11'), 'yyyy-mm-dd\'h\'hh') |&lt;BR /&gt;+---------------------------------------------------------------------------+&lt;BR /&gt;| 2017-04-08'9'09 |&lt;BR /&gt;+---------------------------------------------------------------------------+&lt;BR /&gt;Fetched 1 row(s) in 0.01s&lt;BR /&gt;[i-pvd1c1mgr-vip.vldb-bo.secureworkslab.com:21001] &amp;gt; select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd\\'H\\'HH');&lt;BR /&gt;Query: select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd\\'H\\'HH')&lt;BR /&gt;ERROR: AnalysisException: Syntax error in line 1:&lt;BR /&gt;... 09:10:11'),'yyyy-MM-dd\\'H\\'HH')&lt;BR /&gt;^&lt;BR /&gt;Encountered: IDENTIFIER&lt;BR /&gt;Expected: AND, BETWEEN, DIV, HAVING, ILIKE, IN, IREGEXP, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, RANGE, REGEXP, RLIKE, ROWS, UNION, COMMA&lt;/P&gt;&lt;P&gt;CAUSED BY: Exception: Syntax error&lt;/P&gt;&lt;P&gt;[i-pvd1c1mgr-vip.vldb-bo.secureworkslab.com:21001] &amp;gt; select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd\\\'H\\\'HH');&lt;BR /&gt;Query: select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd\\\'H\\\'HH')&lt;BR /&gt;+-------------------------------------------------------------------------------+&lt;BR /&gt;| from_unixtime(unix_timestamp('2017-04-08 09:10:11'), 'yyyy-mm-dd\\\'h\\\'hh') |&lt;BR /&gt;+-------------------------------------------------------------------------------+&lt;BR /&gt;| 2017-04-08\'9\'09 |&lt;BR /&gt;+-------------------------------------------------------------------------------+&lt;BR /&gt;Fetched 1 row(s) in 0.02s&lt;BR /&gt;[i-pvd1c1mgr-vip.vldb-bo.secureworkslab.com:21001] &amp;gt; select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd''H''HH');&lt;BR /&gt;Query: select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd''H''HH')&lt;BR /&gt;ERROR: AnalysisException: Syntax error in line 1:&lt;BR /&gt;...08 09:10:11'),'yyyy-MM-dd''H''HH')&lt;BR /&gt;^&lt;BR /&gt;Encountered: STRING LITERAL&lt;BR /&gt;Expected: AND, BETWEEN, DIV, HAVING, ILIKE, IN, IREGEXP, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, RANGE, REGEXP, RLIKE, ROWS, UNION, COMMA&lt;/P&gt;&lt;P&gt;CAUSED BY: Exception: Syntax error&lt;/P&gt;</description>
    <pubDate>Fri, 16 Sep 2022 11:27:27 GMT</pubDate>
    <dc:creator>loubershad</dc:creator>
    <dc:date>2022-09-16T11:27:27Z</dc:date>
    <item>
      <title>from_unixtime format with literal H</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/from-unixtime-format-with-literal-H/m-p/53638#M59423</link>
      <description>&lt;P&gt;I would like to use from_unixtime to convert a unix_timestamp to a string in the format 2017-04-13H08 where the 08 is the hour of day. &amp;nbsp;I haven't figured out how I can do that. &amp;nbsp;I've tried several approaches with backslashes and quotes without success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example that would produce 2017-04-13T08.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[i-pvd1c1mgr-vip.vldb-bo.secureworkslab.com:21001] &amp;gt; select from_unixtime(unix_timestamp('2017-04-13 08:10:11'),'yyyy-MM-ddTHH');&lt;BR /&gt;Query: select from_unixtime(unix_timestamp('2017-04-13 08:10:11'),'yyyy-MM-ddTHH')&lt;BR /&gt;+-----------------------------------------------------------------------+&lt;BR /&gt;| from_unixtime(unix_timestamp('2017-04-13 08:10:11'), 'yyyy-mm-ddthh') |&lt;BR /&gt;+-----------------------------------------------------------------------+&lt;BR /&gt;| 2017-04-13T08 |&lt;BR /&gt;+-----------------------------------------------------------------------+&lt;BR /&gt;Fetched 1 row(s) in 0.01s&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are some of my attempts:&lt;/P&gt;&lt;P&gt;[i-pvd1c1mgr-vip.vldb-bo.secureworkslab.com:21001] &amp;gt; select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-ddHHH');&lt;BR /&gt;Query: select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-ddHHH')&lt;BR /&gt;+-----------------------------------------------------------------------+&lt;BR /&gt;| from_unixtime(unix_timestamp('2017-04-08 09:10:11'), 'yyyy-mm-ddhhh') |&lt;BR /&gt;+-----------------------------------------------------------------------+&lt;BR /&gt;| 2017-04-08009 |&lt;BR /&gt;+-----------------------------------------------------------------------+&lt;BR /&gt;Fetched 1 row(s) in 0.02s&lt;BR /&gt;[i-pvd1c1mgr-vip.vldb-bo.secureworkslab.com:21001] &amp;gt; select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd\\HHH');&lt;BR /&gt;Query: select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd\\HHH')&lt;BR /&gt;+-------------------------------------------------------------------------+&lt;BR /&gt;| from_unixtime(unix_timestamp('2017-04-08 09:10:11'), 'yyyy-mm-dd\\hhh') |&lt;BR /&gt;+-------------------------------------------------------------------------+&lt;BR /&gt;| 2017-04-08\009 |&lt;BR /&gt;+-------------------------------------------------------------------------+&lt;BR /&gt;Fetched 1 row(s) in 0.01s&lt;BR /&gt;[i-pvd1c1mgr-vip.vldb-bo.secureworkslab.com:21001] &amp;gt; select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd\'H\'HH');&lt;BR /&gt;Query: select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd\'H\'HH')&lt;BR /&gt;+---------------------------------------------------------------------------+&lt;BR /&gt;| from_unixtime(unix_timestamp('2017-04-08 09:10:11'), 'yyyy-mm-dd\'h\'hh') |&lt;BR /&gt;+---------------------------------------------------------------------------+&lt;BR /&gt;| 2017-04-08'9'09 |&lt;BR /&gt;+---------------------------------------------------------------------------+&lt;BR /&gt;Fetched 1 row(s) in 0.01s&lt;BR /&gt;[i-pvd1c1mgr-vip.vldb-bo.secureworkslab.com:21001] &amp;gt; select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd\\'H\\'HH');&lt;BR /&gt;Query: select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd\\'H\\'HH')&lt;BR /&gt;ERROR: AnalysisException: Syntax error in line 1:&lt;BR /&gt;... 09:10:11'),'yyyy-MM-dd\\'H\\'HH')&lt;BR /&gt;^&lt;BR /&gt;Encountered: IDENTIFIER&lt;BR /&gt;Expected: AND, BETWEEN, DIV, HAVING, ILIKE, IN, IREGEXP, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, RANGE, REGEXP, RLIKE, ROWS, UNION, COMMA&lt;/P&gt;&lt;P&gt;CAUSED BY: Exception: Syntax error&lt;/P&gt;&lt;P&gt;[i-pvd1c1mgr-vip.vldb-bo.secureworkslab.com:21001] &amp;gt; select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd\\\'H\\\'HH');&lt;BR /&gt;Query: select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd\\\'H\\\'HH')&lt;BR /&gt;+-------------------------------------------------------------------------------+&lt;BR /&gt;| from_unixtime(unix_timestamp('2017-04-08 09:10:11'), 'yyyy-mm-dd\\\'h\\\'hh') |&lt;BR /&gt;+-------------------------------------------------------------------------------+&lt;BR /&gt;| 2017-04-08\'9\'09 |&lt;BR /&gt;+-------------------------------------------------------------------------------+&lt;BR /&gt;Fetched 1 row(s) in 0.02s&lt;BR /&gt;[i-pvd1c1mgr-vip.vldb-bo.secureworkslab.com:21001] &amp;gt; select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd''H''HH');&lt;BR /&gt;Query: select from_unixtime(unix_timestamp('2017-04-08 09:10:11'),'yyyy-MM-dd''H''HH')&lt;BR /&gt;ERROR: AnalysisException: Syntax error in line 1:&lt;BR /&gt;...08 09:10:11'),'yyyy-MM-dd''H''HH')&lt;BR /&gt;^&lt;BR /&gt;Encountered: STRING LITERAL&lt;BR /&gt;Expected: AND, BETWEEN, DIV, HAVING, ILIKE, IN, IREGEXP, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, RANGE, REGEXP, RLIKE, ROWS, UNION, COMMA&lt;/P&gt;&lt;P&gt;CAUSED BY: Exception: Syntax error&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 11:27:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/from-unixtime-format-with-literal-H/m-p/53638#M59423</guid>
      <dc:creator>loubershad</dc:creator>
      <dc:date>2022-09-16T11:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: from_unixtime format with literal H</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/from-unixtime-format-with-literal-H/m-p/53642#M59424</link>
      <description>Impala does not support backslashes/quotes to avoid interpretation of&lt;BR /&gt;format letters.&lt;BR /&gt;&lt;BR /&gt;To get the desired format, you can do something like this:&lt;BR /&gt;select regexp_replace(from_unixtime(unix_timestamp('2017-04-13&lt;BR /&gt;08:10:11'),'yyyy-MM-ddTHH'), 'T', 'H');&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Apr 2017 18:27:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/from-unixtime-format-with-literal-H/m-p/53642#M59424</guid>
      <dc:creator>attilaj</dc:creator>
      <dc:date>2017-04-13T18:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: from_unixtime format with literal H</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/from-unixtime-format-with-literal-H/m-p/53957#M59425</link>
      <description>&lt;P&gt;Thank you for your quick response. &amp;nbsp;It's a bit disappointing that impala differs from hive:&lt;/P&gt;&lt;PRE&gt;hive&amp;gt; select from_unixtime(1492677561,'yyyy-MM-dd\'H\'HH');
OK
_c0
2017-04-20H08&lt;/PRE&gt;&lt;P&gt;I've created&amp;nbsp;&lt;A href="https://issues.apache.org/jira/browse/IMPALA-5237&amp;nbsp;" target="_blank"&gt;https://issues.apache.org/jira/browse/IMPALA-5237&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 20:33:02 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/from-unixtime-format-with-literal-H/m-p/53957#M59425</guid>
      <dc:creator>loubershad</dc:creator>
      <dc:date>2017-04-20T20:33:02Z</dc:date>
    </item>
  </channel>
</rss>

