<?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 Azure Databricks: Failed to extract data which is between two timestamps within those same dates using Pyspark in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/azure-databricks-failed-to-extract-data-which-is-between-two/m-p/34755#M25474</link>
    <description>&lt;P&gt;&lt;B&gt;Data type:&lt;/B&gt;&lt;/P&gt;&lt;P&gt;AAPL_Time: timestamp&lt;/P&gt;&lt;P&gt;AAPL_Close: float&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Raw Data:&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;AAPL_Time                                          AAPL_Close
2015-05-11T08:00:00.000+0000   29.0344
2015-05-11T08:30:00.000+0000   29.0187
2015-05-11T09:00:00.000+0000   29.0346
2015-05-11T09:30:00.000+0000   28.763
2015-05-11T10:00:00.000+0000   28.6768
2015-05-11T10:30:00.000+0000   28.7464
2015-05-12T12:30:00.000+0000   28.7915
2015-05-12T13:00:00.000+0000   28.8763
2015-05-12T13:30:00.000+0000   28.8316
2015-05-12T14:00:00.000+0000   28.8418
2015-05-12T14:30:00.000+0000   28.7703&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to extract data by&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;spark.sql("SELECT AAPL_Time, AAPL_Close FROM aapl_table where AAPL_Time between '%09:30:00%' and '%16:30:00%'")&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;I expect the result should be this:&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;AAPL_Time                                          AAPL_Close
&amp;nbsp;
2015-05-11T09:30:00.000+0000   28.763
&amp;nbsp;
2015-05-11T10:00:00.000+0000   28.6768
&amp;nbsp;
2015-05-11T10:30:00.000+0000   28.7464
&amp;nbsp;
2015-05-12T12:30:00.000+0000   28.7915
&amp;nbsp;
2015-05-12T13:00:00.000+0000   28.8763
&amp;nbsp;
2015-05-12T13:30:00.000+0000   28.8316
&amp;nbsp;
2015-05-12T14:00:00.000+0000   28.8418
&amp;nbsp;
2015-05-12T14:30:00.000+0000   28.7703&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Yet, the final result is this:&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Query returned no results&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help me?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Same question in &lt;A href="https://stackoverflow.com/questions/73326977/azure-databricks-failed-to-extract-data-which-is-between-two-timestamps-within?noredirect=1#comment129503156_73326977" alt="https://stackoverflow.com/questions/73326977/azure-databricks-failed-to-extract-data-which-is-between-two-timestamps-within?noredirect=1#comment129503156_73326977" target="_blank"&gt;https://stackoverflow.com/questions/73326977/azure-databricks-failed-to-extract-data-which-is-between-two-timestamps-within?noredirect=1#comment129503156_73326977&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Aug 2022 09:16:46 GMT</pubDate>
    <dc:creator>Dicer</dc:creator>
    <dc:date>2022-08-12T09:16:46Z</dc:date>
    <item>
      <title>Azure Databricks: Failed to extract data which is between two timestamps within those same dates using Pyspark</title>
      <link>https://community.databricks.com/t5/data-engineering/azure-databricks-failed-to-extract-data-which-is-between-two/m-p/34755#M25474</link>
      <description>&lt;P&gt;&lt;B&gt;Data type:&lt;/B&gt;&lt;/P&gt;&lt;P&gt;AAPL_Time: timestamp&lt;/P&gt;&lt;P&gt;AAPL_Close: float&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Raw Data:&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;AAPL_Time                                          AAPL_Close
2015-05-11T08:00:00.000+0000   29.0344
2015-05-11T08:30:00.000+0000   29.0187
2015-05-11T09:00:00.000+0000   29.0346
2015-05-11T09:30:00.000+0000   28.763
2015-05-11T10:00:00.000+0000   28.6768
2015-05-11T10:30:00.000+0000   28.7464
2015-05-12T12:30:00.000+0000   28.7915
2015-05-12T13:00:00.000+0000   28.8763
2015-05-12T13:30:00.000+0000   28.8316
2015-05-12T14:00:00.000+0000   28.8418
2015-05-12T14:30:00.000+0000   28.7703&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to extract data by&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;spark.sql("SELECT AAPL_Time, AAPL_Close FROM aapl_table where AAPL_Time between '%09:30:00%' and '%16:30:00%'")&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;I expect the result should be this:&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;AAPL_Time                                          AAPL_Close
&amp;nbsp;
2015-05-11T09:30:00.000+0000   28.763
&amp;nbsp;
2015-05-11T10:00:00.000+0000   28.6768
&amp;nbsp;
2015-05-11T10:30:00.000+0000   28.7464
&amp;nbsp;
2015-05-12T12:30:00.000+0000   28.7915
&amp;nbsp;
2015-05-12T13:00:00.000+0000   28.8763
&amp;nbsp;
2015-05-12T13:30:00.000+0000   28.8316
&amp;nbsp;
2015-05-12T14:00:00.000+0000   28.8418
&amp;nbsp;
2015-05-12T14:30:00.000+0000   28.7703&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Yet, the final result is this:&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Query returned no results&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help me?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Same question in &lt;A href="https://stackoverflow.com/questions/73326977/azure-databricks-failed-to-extract-data-which-is-between-two-timestamps-within?noredirect=1#comment129503156_73326977" alt="https://stackoverflow.com/questions/73326977/azure-databricks-failed-to-extract-data-which-is-between-two-timestamps-within?noredirect=1#comment129503156_73326977" target="_blank"&gt;https://stackoverflow.com/questions/73326977/azure-databricks-failed-to-extract-data-which-is-between-two-timestamps-within?noredirect=1#comment129503156_73326977&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2022 09:16:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/azure-databricks-failed-to-extract-data-which-is-between-two/m-p/34755#M25474</guid>
      <dc:creator>Dicer</dc:creator>
      <dc:date>2022-08-12T09:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: Azure Databricks: Failed to extract data which is between two timestamps within those same dates using Pyspark</title>
      <link>https://community.databricks.com/t5/data-engineering/azure-databricks-failed-to-extract-data-which-is-between-two/m-p/34756#M25475</link>
      <description>&lt;P&gt;Hi, maybe you can use the date_format function and retrieve hour and minutes as string&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import  pyspark.sql.functions as F
aapl_table.filter(
    F.date_format(F.col('AAPL_Time '),'HHmm').between("0930","1630")
  )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the version in pyspark, if you want to do in spark sql you can try&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;display(spark.sql("SELECT Aapl_Time, AApl_Close FROM aapl_table where DATE_FORMAT(Aapl_Time,'HHmm') between '0930' and '1630'"))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Let me know if it helped.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2022 13:59:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/azure-databricks-failed-to-extract-data-which-is-between-two/m-p/34756#M25475</guid>
      <dc:creator>Pholo</dc:creator>
      <dc:date>2022-08-12T13:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Azure Databricks: Failed to extract data which is between two timestamps within those same dates using Pyspark</title>
      <link>https://community.databricks.com/t5/data-engineering/azure-databricks-failed-to-extract-data-which-is-between-two/m-p/34757#M25476</link>
      <description>&lt;P&gt;It works. Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2022 14:51:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/azure-databricks-failed-to-extract-data-which-is-between-two/m-p/34757#M25476</guid>
      <dc:creator>Dicer</dc:creator>
      <dc:date>2022-08-12T14:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Azure Databricks: Failed to extract data which is between two timestamps within those same dates using Pyspark</title>
      <link>https://community.databricks.com/t5/data-engineering/azure-databricks-failed-to-extract-data-which-is-between-two/m-p/34758#M25477</link>
      <description>&lt;P&gt;I'm glad that It helped &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2022 14:55:53 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/azure-databricks-failed-to-extract-data-which-is-between-two/m-p/34758#M25477</guid>
      <dc:creator>Pholo</dc:creator>
      <dc:date>2022-08-12T14:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Azure Databricks: Failed to extract data which is between two timestamps within those same dates using Pyspark</title>
      <link>https://community.databricks.com/t5/data-engineering/azure-databricks-failed-to-extract-data-which-is-between-two/m-p/34759#M25478</link>
      <description>&lt;P&gt;Another thing to try is the hour() and minute() functions will return integers.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2022 22:50:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/azure-databricks-failed-to-extract-data-which-is-between-two/m-p/34759#M25478</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-13T22:50:10Z</dc:date>
    </item>
  </channel>
</rss>

