<?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: Unable to convert to date from datetime string with AM and PM in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/unable-to-convert-to-date-from-datetime-string-with-am-and-pm/m-p/102862#M41254</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/110498"&gt;@David_Billa&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Can you try with:&lt;/P&gt;
&lt;P class="p1"&gt;TO_TIMESTAMP("12/30/2022 12:00:00 AM", "MM/dd/yyyy hh:mm:ss a") AS tsDate&lt;/P&gt;
&lt;P class="p1"&gt;The issue you are encountering with the TO_DATE function returning null for the value "12:00:00 AM" is likely due to the format string not matching the input string correctly. The TO_DATE function in Databricks requires the format string to precisely match the input string for it to parse the date correctly&lt;/P&gt;
&lt;P class="p1"&gt;&lt;A href="https://docs.databricks.com/ja/sql/language-manual/functions/to_timestamp.html" target="_blank"&gt;https://docs.databricks.com/ja/sql/language-manual/functions/to_timestamp.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Dec 2024 19:20:19 GMT</pubDate>
    <dc:creator>Alberto_Umana</dc:creator>
    <dc:date>2024-12-20T19:20:19Z</dc:date>
    <item>
      <title>Unable to convert to date from datetime string with AM and PM</title>
      <link>https://community.databricks.com/t5/data-engineering/unable-to-convert-to-date-from-datetime-string-with-am-and-pm/m-p/102861#M41253</link>
      <description>&lt;P&gt;Any help to understand why it's showing 'null' instead of the date value? It's showing null only for 12:00:00 AM and for any other values it's showing date correctly&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;TO_DATE("12/30/2022 12:00:00 AM", "MM/dd/yyyy HH:mm:ss a") AS tsDate&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2024 18:54:41 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/unable-to-convert-to-date-from-datetime-string-with-am-and-pm/m-p/102861#M41253</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2024-12-20T18:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to convert to date from datetime string with AM and PM</title>
      <link>https://community.databricks.com/t5/data-engineering/unable-to-convert-to-date-from-datetime-string-with-am-and-pm/m-p/102862#M41254</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/110498"&gt;@David_Billa&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Can you try with:&lt;/P&gt;
&lt;P class="p1"&gt;TO_TIMESTAMP("12/30/2022 12:00:00 AM", "MM/dd/yyyy hh:mm:ss a") AS tsDate&lt;/P&gt;
&lt;P class="p1"&gt;The issue you are encountering with the TO_DATE function returning null for the value "12:00:00 AM" is likely due to the format string not matching the input string correctly. The TO_DATE function in Databricks requires the format string to precisely match the input string for it to parse the date correctly&lt;/P&gt;
&lt;P class="p1"&gt;&lt;A href="https://docs.databricks.com/ja/sql/language-manual/functions/to_timestamp.html" target="_blank"&gt;https://docs.databricks.com/ja/sql/language-manual/functions/to_timestamp.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2024 19:20:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/unable-to-convert-to-date-from-datetime-string-with-am-and-pm/m-p/102862#M41254</guid>
      <dc:creator>Alberto_Umana</dc:creator>
      <dc:date>2024-12-20T19:20:19Z</dc:date>
    </item>
  </channel>
</rss>

