<?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: Hive - why doesn't truncate support a DD/Day value? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-why-doesn-t-truncate-support-a-DD-Day-value/m-p/101433#M14132</link>
    <description>&lt;P&gt;Through experiments I found this one works as expected:&lt;/P&gt;&lt;PRE&gt;jdbc:hive2://&amp;gt; select date_sub(current_timestamp(), 0);
OK
+-------------+--+
|     _c0     |
+-------------+--+
| 2016-01-05  |
+-------------+--+
&lt;/PRE&gt;&lt;P&gt;Which is much harder than it should be. Given how much legacy SQL there is relying on trunc(timestamp), can we enhance the Hive's function to throw the timestamp out too maybe?&lt;/P&gt;</description>
    <pubDate>Tue, 05 Jan 2016 22:42:56 GMT</pubDate>
    <dc:creator>andrewg</dc:creator>
    <dc:date>2016-01-05T22:42:56Z</dc:date>
    <item>
      <title>Hive - why doesn't truncate support a DD/Day value?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-why-doesn-t-truncate-support-a-DD-Day-value/m-p/101432#M14131</link>
      <description>&lt;P&gt;From the &lt;A target="_blank" href="https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-DateFunctions"&gt;https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-DateFunctions&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;trunc(string date, string format)&lt;/PRE&gt;&lt;P&gt;I'm executing these commands in beeline:&lt;/P&gt;&lt;PRE&gt;0: jdbc:hive2://&amp;gt; select trunc(current_timestamp(), 'MM');
OK
+-------------+--+
|     _c0     |
+-------------+--+
| 2016-01-01  |
+-------------+--+
1 row selected (0.97 seconds)
0: jdbc:hive2://&amp;gt; select trunc(current_timestamp(), 'DD');
OK
+-------+--+
|  _c0  |
+-------+--+
| NULL  |
+-------+--+
1 row selected (0.241 seconds)
&lt;/PRE&gt;&lt;P&gt;Now, the question is why doesn't it support a day value? This is such a natural function for truncating timestamps to a day only.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 22:32:16 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-why-doesn-t-truncate-support-a-DD-Day-value/m-p/101432#M14131</guid>
      <dc:creator>andrewg</dc:creator>
      <dc:date>2016-01-05T22:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: Hive - why doesn't truncate support a DD/Day value?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-why-doesn-t-truncate-support-a-DD-Day-value/m-p/101433#M14132</link>
      <description>&lt;P&gt;Through experiments I found this one works as expected:&lt;/P&gt;&lt;PRE&gt;jdbc:hive2://&amp;gt; select date_sub(current_timestamp(), 0);
OK
+-------------+--+
|     _c0     |
+-------------+--+
| 2016-01-05  |
+-------------+--+
&lt;/PRE&gt;&lt;P&gt;Which is much harder than it should be. Given how much legacy SQL there is relying on trunc(timestamp), can we enhance the Hive's function to throw the timestamp out too maybe?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 22:42:56 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-why-doesn-t-truncate-support-a-DD-Day-value/m-p/101433#M14132</guid>
      <dc:creator>andrewg</dc:creator>
      <dc:date>2016-01-05T22:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Hive - why doesn't truncate support a DD/Day value?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-why-doesn-t-truncate-support-a-DD-Day-value/m-p/101434#M14133</link>
      <description>&lt;P&gt;I found that to_date() function generates correct data types which will work correctly with comparisons and ordering.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2016 00:46:46 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-why-doesn-t-truncate-support-a-DD-Day-value/m-p/101434#M14133</guid>
      <dc:creator>andrewg</dc:creator>
      <dc:date>2016-01-06T00:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: Hive - why doesn't truncate support a DD/Day value?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-why-doesn-t-truncate-support-a-DD-Day-value/m-p/304968#M14134</link>
      <description>&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Hi there,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I was able to get this to work in my select but not in my where clause - any advice?&amp;nbsp; Thank you in advance!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Select&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;date_sub&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;start_time&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt; &lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;anchor_id&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;From&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;a.b&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;where&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;date&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; max_pt&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;a.b&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;and&lt;/SPAN&gt;&lt;SPAN&gt; date_sub&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;start_time&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt; &lt;SPAN&gt;&amp;gt;=&lt;/SPAN&gt; &lt;SPAN&gt;'${date-28}'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 28 Oct 2020 10:21:13 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-why-doesn-t-truncate-support-a-DD-Day-value/m-p/304968#M14134</guid>
      <dc:creator>Aanch</dc:creator>
      <dc:date>2020-10-28T10:21:13Z</dc:date>
    </item>
  </channel>
</rss>

