<?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: Convert string date to date after changing format in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/convert-string-date-to-date-after-changing-format/m-p/39363#M5621</link>
    <description>&lt;P&gt;if you use to_date, you will get a date column as mentioned above.&lt;BR /&gt;If you want to use the format MM/dd/yyyy you can use date_format but this will return a string column.&lt;/P&gt;&lt;P&gt;In order to use Spark date functions, Date string should comply with Spark DateType format which is ‘yyyy-MM-dd’ .&lt;/P&gt;</description>
    <pubDate>Tue, 08 Aug 2023 13:47:54 GMT</pubDate>
    <dc:creator>-werners-</dc:creator>
    <dc:date>2023-08-08T13:47:54Z</dc:date>
    <item>
      <title>Convert string date to date after changing format</title>
      <link>https://community.databricks.com/t5/get-started-discussions/convert-string-date-to-date-after-changing-format/m-p/39292#M5619</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using Data bricks SQL and came across a scenario. I have a date field whose dates are in format of 'YYYY-MM-DD'. I changed their format into 'MM/DD/YYYY' using DATE_FORMAT() function.&lt;/P&gt;&lt;P&gt;EFF_DT = &lt;SPAN&gt;2000-01-14&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;EFF_DT _2 = DATE_FORMAT(EFF_DT, 'MM/dd/yyyy') &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;DATE_FORMAT() returns a string with with the format 01/14/2000. Now when I am trying to convert this string back to date with the same format using TO_DATE function, I am getting 2000-01-14 instead of 01/14/2000.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;EFF_DT _3 =  TO_DATE(DATE_FORMAT(EFF_DT, 'MM/dd/yyyy'), 'MM/dd/yyyy')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want eff_dt_3 = 01/14/2000 as date. Can anyone help me out.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;EFF_DT&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;EFF_DT_2&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN&gt;EFF_DT_3 &lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN&gt;2000-01-14&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN&gt;01/14/2000&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN&gt;2000-01-14&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2023 18:29:49 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/convert-string-date-to-date-after-changing-format/m-p/39292#M5619</guid>
      <dc:creator>shanmukh_b</dc:creator>
      <dc:date>2023-08-07T18:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: Convert string date to date after changing format</title>
      <link>https://community.databricks.com/t5/get-started-discussions/convert-string-date-to-date-after-changing-format/m-p/39363#M5621</link>
      <description>&lt;P&gt;if you use to_date, you will get a date column as mentioned above.&lt;BR /&gt;If you want to use the format MM/dd/yyyy you can use date_format but this will return a string column.&lt;/P&gt;&lt;P&gt;In order to use Spark date functions, Date string should comply with Spark DateType format which is ‘yyyy-MM-dd’ .&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 13:47:54 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/convert-string-date-to-date-after-changing-format/m-p/39363#M5621</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2023-08-08T13:47:54Z</dc:date>
    </item>
  </channel>
</rss>

