<?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: How to retrieve Latest Uploaded records from Hive , In my table dont DATE column , Only  Modified Timestamp Column only Available ? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-retrieve-Latest-Uploaded-records-from-Hive-In-my/m-p/187071#M75879</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/68258/nittala999.html" nodeid="68258"&gt;@Satya Nittala&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You can use&lt;STRONG&gt; to_date&lt;/STRONG&gt; function in your where clause to get only the max(Last uploaded date) records.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Example:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I'm having a table &lt;/P&gt;&lt;PRE&gt;hive&amp;gt; select * from test_table;
+-----+-------+-----------+----------------------+--+
| id  | name  |    dt     |        daily         |
+-----+-------+-----------+----------------------+--+
| 1   | hcc   | 12:00:00  | 2017-10-10 12:00:00  |
| 1   | foo   | 12:00:00  | 2017-10-11 12:00:00  |
| 1   | foo   | 12:00:00  | 2017-10-12 12:00:00  |
| 2   | bar   | 09:00:00  | 2017-12-23 09:00:00  |
| 3   | foo   | 09:00:00  | 2018-03-15 09:00:00  |
| 4   | bar   | 09:00:00  | 2018-03-15 09:00:00  |
+-----+-------+-----------+----------------------+--+
&lt;/PRE&gt;&lt;P&gt;Now i want to get only the records that having max date i.e 2017-03-15 is our max date.&lt;/P&gt;&lt;PRE&gt;hive&amp;gt; select count(*) from test_table where to_Date(daily) in (select max(to_Date(daily)) from test_table);&lt;/PRE&gt;&lt;PRE&gt;+------+--+
| _c0  |
+------+--+
| 2    |
+------+--+&lt;/PRE&gt;&lt;P&gt;As i have got only 2 records because there are 2 records in the table that are having 2018-03-15 as date in daily column and we have used to_Date function it will extract only the date from timestamp.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;to_date function:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;hive&amp;gt; select to_date(daily) from test_table;
+-------------+--+
|     _c0     |
+-------------+--+
| 2017-10-10  |
| 2017-10-11  |
| 2017-10-12  |
| 2017-12-23  |
| 2018-03-15  |
| 2018-03-15  |
+-------------+--+


&lt;/PRE&gt;&lt;P&gt;Let us know if you having some issues..!!&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;If the Answer helped to resolve your issue, &lt;STRONG&gt;Click on Accept button below to accept the answer&lt;/STRONG&gt;, That would be great help to Community users to find solution quickly for these kind of issues.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Mar 2018 20:07:16 GMT</pubDate>
    <dc:creator>Shu_ashu</dc:creator>
    <dc:date>2018-03-15T20:07:16Z</dc:date>
    <item>
      <title>How to retrieve Latest Uploaded records from Hive , In my table dont DATE column , Only  Modified Timestamp Column only Available ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-retrieve-Latest-Uploaded-records-from-Hive-In-my/m-p/187070#M75878</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;I want to retrieve the recent uploaded records in &lt;STRONG&gt;&lt;U&gt;that day&lt;/U&gt;&lt;/STRONG&gt;  , My table dont have Date column , But Time stamp column is availble&lt;/P&gt;&lt;P&gt;Example : Last uploaded date is 2018-03-15&lt;/P&gt;&lt;P&gt;Upload happens in below Time &lt;/P&gt;&lt;P&gt;2018-03-07 01:13:26 &lt;/P&gt;&lt;P&gt;
2018-03-07 01:13:34 &lt;/P&gt;&lt;P&gt;
2018-03-07 01:13:39 &lt;/P&gt;&lt;P&gt;
2018-03-07 01:13:43 &lt;/P&gt;&lt;P&gt;
2018-03-07 01:13:50 &lt;/P&gt;&lt;P&gt;
2018-03-07 01:13:54 &lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Now i want to find latest upload date , In that date how many records are uploaded ?&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;In where condition i can able to give only one time stamp ( Max time stamp ), So In that day remaining time stamps how can i give ?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 17:18:06 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-retrieve-Latest-Uploaded-records-from-Hive-In-my/m-p/187070#M75878</guid>
      <dc:creator>nittala999</dc:creator>
      <dc:date>2018-03-15T17:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve Latest Uploaded records from Hive , In my table dont DATE column , Only  Modified Timestamp Column only Available ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-retrieve-Latest-Uploaded-records-from-Hive-In-my/m-p/187071#M75879</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/68258/nittala999.html" nodeid="68258"&gt;@Satya Nittala&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You can use&lt;STRONG&gt; to_date&lt;/STRONG&gt; function in your where clause to get only the max(Last uploaded date) records.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Example:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I'm having a table &lt;/P&gt;&lt;PRE&gt;hive&amp;gt; select * from test_table;
+-----+-------+-----------+----------------------+--+
| id  | name  |    dt     |        daily         |
+-----+-------+-----------+----------------------+--+
| 1   | hcc   | 12:00:00  | 2017-10-10 12:00:00  |
| 1   | foo   | 12:00:00  | 2017-10-11 12:00:00  |
| 1   | foo   | 12:00:00  | 2017-10-12 12:00:00  |
| 2   | bar   | 09:00:00  | 2017-12-23 09:00:00  |
| 3   | foo   | 09:00:00  | 2018-03-15 09:00:00  |
| 4   | bar   | 09:00:00  | 2018-03-15 09:00:00  |
+-----+-------+-----------+----------------------+--+
&lt;/PRE&gt;&lt;P&gt;Now i want to get only the records that having max date i.e 2017-03-15 is our max date.&lt;/P&gt;&lt;PRE&gt;hive&amp;gt; select count(*) from test_table where to_Date(daily) in (select max(to_Date(daily)) from test_table);&lt;/PRE&gt;&lt;PRE&gt;+------+--+
| _c0  |
+------+--+
| 2    |
+------+--+&lt;/PRE&gt;&lt;P&gt;As i have got only 2 records because there are 2 records in the table that are having 2018-03-15 as date in daily column and we have used to_Date function it will extract only the date from timestamp.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;to_date function:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;hive&amp;gt; select to_date(daily) from test_table;
+-------------+--+
|     _c0     |
+-------------+--+
| 2017-10-10  |
| 2017-10-11  |
| 2017-10-12  |
| 2017-12-23  |
| 2018-03-15  |
| 2018-03-15  |
+-------------+--+


&lt;/PRE&gt;&lt;P&gt;Let us know if you having some issues..!!&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;If the Answer helped to resolve your issue, &lt;STRONG&gt;Click on Accept button below to accept the answer&lt;/STRONG&gt;, That would be great help to Community users to find solution quickly for these kind of issues.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 20:07:16 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-retrieve-Latest-Uploaded-records-from-Hive-In-my/m-p/187071#M75879</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2018-03-15T20:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve Latest Uploaded records from Hive , In my table dont DATE column , Only  Modified Timestamp Column only Available ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-retrieve-Latest-Uploaded-records-from-Hive-In-my/m-p/187072#M75880</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/18929/yaswanthmuppireddy.html" nodeid="18929"&gt;@Shu&lt;/A&gt; , Thank You...its working..&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 17:38:09 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-retrieve-Latest-Uploaded-records-from-Hive-In-my/m-p/187072#M75880</guid>
      <dc:creator>nittala999</dc:creator>
      <dc:date>2018-03-20T17:38:09Z</dc:date>
    </item>
  </channel>
</rss>

