<?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>topic Re: Filter data by Date using where condition (&amp;lt; TargetDate) giving &amp;quot;Query returned no results&amp;quot; in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/filter-data-by-date-using-where-condition-lt-targetdate-giving/m-p/11110#M6138</link>
    <description>&lt;P&gt;Hi @Rishabh Shankar​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We'd love to hear from you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Sep 2022 12:15:38 GMT</pubDate>
    <dc:creator>Vidula</dc:creator>
    <dc:date>2022-09-07T12:15:38Z</dc:date>
    <item>
      <title>Filter data by Date using where condition (&lt; TargetDate) giving "Query returned no results"</title>
      <link>https://community.databricks.com/t5/data-engineering/filter-data-by-date-using-where-condition-lt-targetdate-giving/m-p/11106#M6134</link>
      <description>&lt;P&gt;Code is working good if data greater than target date (&amp;gt;) is selected :&lt;/P&gt;&lt;P&gt;SELECT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;xyz.ID,&lt;/P&gt;&lt;P&gt;xyz.Gender,&lt;/P&gt;&lt;P&gt;xyz.geography,&lt;/P&gt;&lt;P&gt;xyz.code,&lt;/P&gt;&lt;P&gt;xyz.delivery_status,&lt;/P&gt;&lt;P&gt;abc.department_code&lt;/P&gt;&lt;P&gt;FROM v.table1 as xyz&lt;/P&gt;&lt;P&gt;left join y.table2 as abc&lt;/P&gt;&lt;P&gt;on&lt;/P&gt;&lt;P&gt;xyz.ID = abc.ID AND&amp;nbsp;&lt;/P&gt;&lt;P&gt;xyz.code =&amp;nbsp;abc.code&lt;/P&gt;&lt;P&gt;where xyz.partition_date &amp;lt; '2021-01-01'&amp;nbsp;&lt;/P&gt;&lt;P&gt;group by 1,2,3,4,5,6&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-- It's working when using xyz.partition_date &amp;gt;= 2020-01-31&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@Aman Sehgal​&amp;nbsp; @Stephan Lawson​&amp;nbsp; @Darryll Petrancuri​&amp;nbsp; @sql-thetan​&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2022 17:17:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/filter-data-by-date-using-where-condition-lt-targetdate-giving/m-p/11106#M6134</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-05T17:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Filter data by Date using where condition (&lt; TargetDate) giving "Query returned no results"</title>
      <link>https://community.databricks.com/t5/data-engineering/filter-data-by-date-using-where-condition-lt-targetdate-giving/m-p/11107#M6135</link>
      <description>&lt;P&gt;The fact that you get records for &amp;gt;= 2020-01-31 doesn't mean you should get something for &amp;lt; 2021-01-01 as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let's say the set contains the date 2099-01-01. Then, when applying the first condition, you will see the corresponding row, but applying the second one you will get "Query returned no results" which makes sense.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Aug 2022 13:26:21 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/filter-data-by-date-using-where-condition-lt-targetdate-giving/m-p/11107#M6135</guid>
      <dc:creator>artsheiko</dc:creator>
      <dc:date>2022-08-07T13:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: Filter data by Date using where condition (&lt; TargetDate) giving "Query returned no results"</title>
      <link>https://community.databricks.com/t5/data-engineering/filter-data-by-date-using-where-condition-lt-targetdate-giving/m-p/11108#M6136</link>
      <description>&lt;P&gt;Hi @Artem Sheiko​&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your answer. The problem is data is available from 2017-01-01 to current date. And if I search for records &amp;gt; 2017-01-01 it will work but if I do same for &amp;lt; Any Date (Let' say 2022-01-01) It will give no results. "Between" any date range is also not working.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Aug 2022 18:09:42 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/filter-data-by-date-using-where-condition-lt-targetdate-giving/m-p/11108#M6136</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-07T18:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: Filter data by Date using where condition (&lt; TargetDate) giving "Query returned no results"</title>
      <link>https://community.databricks.com/t5/data-engineering/filter-data-by-date-using-where-condition-lt-targetdate-giving/m-p/11109#M6137</link>
      <description>&lt;P&gt;When comparing date fields, results can sometimes be erroneous. &lt;/P&gt;&lt;P&gt;From what your explanation above, I can recommend following for you:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Check number of rows in each date partition. It looks like all your data from 2017-01-01 could be sitting in one partition and hence you're getting no results for less than and between query but you're getting results for greater than query.&lt;/LI&gt;&lt;/UL&gt;&lt;PRE&gt;&lt;CODE&gt;select partition_date, count(*) from v.table1 group by partition_date having count(*)&amp;gt;0 &lt;/CODE&gt;&lt;/PRE&gt;&lt;UL&gt;&lt;LI&gt;Use to_date in your query for comparing dates.&lt;/LI&gt;&lt;/UL&gt;&lt;PRE&gt;&lt;CODE&gt;select to_date(partition_date, 'yyyy-MM-dd') as partition_dt from v.table1&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2022 04:56:25 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/filter-data-by-date-using-where-condition-lt-targetdate-giving/m-p/11109#M6137</guid>
      <dc:creator>AmanSehgal</dc:creator>
      <dc:date>2022-08-08T04:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: Filter data by Date using where condition (&lt; TargetDate) giving "Query returned no results"</title>
      <link>https://community.databricks.com/t5/data-engineering/filter-data-by-date-using-where-condition-lt-targetdate-giving/m-p/11110#M6138</link>
      <description>&lt;P&gt;Hi @Rishabh Shankar​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We'd love to hear from you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 12:15:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/filter-data-by-date-using-where-condition-lt-targetdate-giving/m-p/11110#M6138</guid>
      <dc:creator>Vidula</dc:creator>
      <dc:date>2022-09-07T12:15:38Z</dc:date>
    </item>
  </channel>
</rss>

