<?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: String converstion to datetimestamp format in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/string-converstion-to-datetimestamp-format/m-p/27941#M19779</link>
    <description>&lt;P&gt;@sri vs​&amp;nbsp;maybe concatenate the two strings and use to_timestamp with the format specified? &lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/spark/latest/spark-sql/language-manual/functions/to_timestamp.html" alt="https://docs.databricks.com/spark/latest/spark-sql/language-manual/functions/to_timestamp.html" target="_blank"&gt;https://docs.databricks.com/spark/latest/spark-sql/language-manual/functions/to_timestamp.html&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/spark/latest/spark-sql/language-manual/functions/concat.html" alt="https://docs.databricks.com/spark/latest/spark-sql/language-manual/functions/concat.html" target="_blank"&gt;https://docs.databricks.com/spark/latest/spark-sql/language-manual/functions/concat.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;creating timestamp:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;spark.sql("select to_timestamp(concat('20221009','010911'),'yyyyMMddhhmmss') as my_date").display()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;formatted with AM /PM:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;spark.sql("select date_format(to_timestamp(concat('20221009','010911'),'yyyyMMddhhmmss'),'yyyy-MM-dd hh:mm:ss a') as my_date").display()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Oct 2022 13:57:12 GMT</pubDate>
    <dc:creator>Matt101122</dc:creator>
    <dc:date>2022-10-12T13:57:12Z</dc:date>
    <item>
      <title>String converstion to datetimestamp format</title>
      <link>https://community.databricks.com/t5/data-engineering/string-converstion-to-datetimestamp-format/m-p/27940#M19778</link>
      <description>&lt;P&gt;Hello &lt;/P&gt;&lt;P&gt;i'm converting hana sql code in databricks. we have 4 columns all in string format, start date, start time, end date, endtime..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) what expression i can use  to convert values of   startdate &amp;amp; start time from string format to  datetimeformat with AM/PM .? so later i can break final value in to two columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;expected value:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Startdate ,,  Starttime&lt;/P&gt;&lt;P&gt;2022-10-09  01-09-11 am&lt;/P&gt;&lt;P&gt;2022-10-09 -08-20-16 am (3rd row).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1377i1DEF1832D0D2AA4B/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 19:37:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/string-converstion-to-datetimestamp-format/m-p/27940#M19778</guid>
      <dc:creator>refint650</dc:creator>
      <dc:date>2022-10-11T19:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: String converstion to datetimestamp format</title>
      <link>https://community.databricks.com/t5/data-engineering/string-converstion-to-datetimestamp-format/m-p/27941#M19779</link>
      <description>&lt;P&gt;@sri vs​&amp;nbsp;maybe concatenate the two strings and use to_timestamp with the format specified? &lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/spark/latest/spark-sql/language-manual/functions/to_timestamp.html" alt="https://docs.databricks.com/spark/latest/spark-sql/language-manual/functions/to_timestamp.html" target="_blank"&gt;https://docs.databricks.com/spark/latest/spark-sql/language-manual/functions/to_timestamp.html&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/spark/latest/spark-sql/language-manual/functions/concat.html" alt="https://docs.databricks.com/spark/latest/spark-sql/language-manual/functions/concat.html" target="_blank"&gt;https://docs.databricks.com/spark/latest/spark-sql/language-manual/functions/concat.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;creating timestamp:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;spark.sql("select to_timestamp(concat('20221009','010911'),'yyyyMMddhhmmss') as my_date").display()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;formatted with AM /PM:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;spark.sql("select date_format(to_timestamp(concat('20221009','010911'),'yyyyMMddhhmmss'),'yyyy-MM-dd hh:mm:ss a') as my_date").display()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 13:57:12 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/string-converstion-to-datetimestamp-format/m-p/27941#M19779</guid>
      <dc:creator>Matt101122</dc:creator>
      <dc:date>2022-10-12T13:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: String converstion to datetimestamp format</title>
      <link>https://community.databricks.com/t5/data-engineering/string-converstion-to-datetimestamp-format/m-p/27942#M19780</link>
      <description>&lt;P&gt;Hello Matt&lt;/P&gt;&lt;P&gt;concat &amp;amp; to_timstamp function partially worked,  values with 24 timestamp format not converted. any other approach  i can think .?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1370i3018FCA89F0F52BB/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 14:15:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/string-converstion-to-datetimestamp-format/m-p/27942#M19780</guid>
      <dc:creator>refint650</dc:creator>
      <dc:date>2022-10-12T14:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: String converstion to datetimestamp format</title>
      <link>https://community.databricks.com/t5/data-engineering/string-converstion-to-datetimestamp-format/m-p/27943#M19781</link>
      <description>&lt;P&gt;@sri vs​&amp;nbsp;if the hours are 0-23 then you'll have to use HH instead of hh:&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/spark/latest/spark-sql/language-manual/sql-ref-datetime-pattern.html#pattern-table" target="test_blank"&gt;https://docs.databricks.com/spark/latest/spark-sql/language-manual/sql-ref-datetime-pattern.html#pattern-table&lt;/A&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;spark.sql("select date_format(to_timestamp(concat('20221009','010911'),'yyyyMMddHHmmss'),'yyyy-MM-dd hh:mm:ss a') as my_date").display()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 14:19:13 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/string-converstion-to-datetimestamp-format/m-p/27943#M19781</guid>
      <dc:creator>Matt101122</dc:creator>
      <dc:date>2022-10-12T14:19:13Z</dc:date>
    </item>
    <item>
      <title>Re: String converstion to datetimestamp format</title>
      <link>https://community.databricks.com/t5/data-engineering/string-converstion-to-datetimestamp-format/m-p/27944#M19782</link>
      <description>&lt;P&gt; last expression worked as charm : thank you&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 14:24:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/string-converstion-to-datetimestamp-format/m-p/27944#M19782</guid>
      <dc:creator>refint650</dc:creator>
      <dc:date>2022-10-12T14:24:44Z</dc:date>
    </item>
  </channel>
</rss>

