<?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: How to convert string to datetime with correct timezone? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-convert-string-to-datetime-with-correct-timezone/m-p/10747#M5846</link>
    <description>&lt;P&gt;Use to_utc_timestamp(expr,timezone)​&lt;/P&gt;</description>
    <pubDate>Sat, 04 Feb 2023 14:30:06 GMT</pubDate>
    <dc:creator>Manoj12421</dc:creator>
    <dc:date>2023-02-04T14:30:06Z</dc:date>
    <item>
      <title>How to convert string to datetime with correct timezone?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-convert-string-to-datetime-with-correct-timezone/m-p/10741#M5840</link>
      <description>&lt;P&gt;I have a field stored as a string in the format "12/30/2022 10:30:00 AM"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If I use the function TO_DATE, I only get the date part... I want the full date and time.&lt;/LI&gt;&lt;LI&gt;If I use the function TO_TIMESTAMP, I get the date and time, but it's assumed to be UTC, which isn't correct (it's actually the local timezone where the data was originally hosted)&lt;/LI&gt;&lt;LI&gt;I can potentially use MAKE_TIMESTAMP, but I have to do a lot of string manipulation to get all the components&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the easiest way to convert the string into a timestamp, with the timezone of my choosing?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2023 04:33:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-convert-string-to-datetime-with-correct-timezone/m-p/10741#M5840</guid>
      <dc:creator>najmead</dc:creator>
      <dc:date>2023-01-25T04:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to datetime with correct timezone?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-convert-string-to-datetime-with-correct-timezone/m-p/10742#M5841</link>
      <description>&lt;P&gt;@Nicholas Mead​&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use TO_TIMESTAMP() function with format parameter.&lt;/P&gt;&lt;P&gt;Ex. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TO_TIMESTAMP("12/30/2022 10:30:00 AM", "MM/dd/yyyy HH:mm:ss a") AS tsDate&lt;/CODE&gt;&lt;/PRE&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/802i6D7E302574EAA806/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2023 06:42:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-convert-string-to-datetime-with-correct-timezone/m-p/10742#M5841</guid>
      <dc:creator>daniel_sahal</dc:creator>
      <dc:date>2023-01-25T06:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to datetime with correct timezone?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-convert-string-to-datetime-with-correct-timezone/m-p/10743#M5842</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use this to get the time zone of your choosing:&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/795i10A800ABEC47752D/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2023 12:07:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-convert-string-to-datetime-with-correct-timezone/m-p/10743#M5842</guid>
      <dc:creator>SRK</dc:creator>
      <dc:date>2023-01-25T12:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to datetime with correct timezone?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-convert-string-to-datetime-with-correct-timezone/m-p/10744#M5843</link>
      <description>&lt;P&gt;I don't seem to be getting the same result... note no timezone info in my results;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a config setting I'm missing or something?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 07:06:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-convert-string-to-datetime-with-correct-timezone/m-p/10744#M5843</guid>
      <dc:creator>najmead</dc:creator>
      <dc:date>2023-01-30T07:06:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to datetime with correct timezone?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-convert-string-to-datetime-with-correct-timezone/m-p/10745#M5844</link>
      <description>&lt;P&gt;Just to answer my own question, in case anyone else googles for this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FirstIy, don't know why timezone isn't displaying in my query results using a SQL Warehouse, but it works ok using a compute cluster, so I'm guessing it is a display issue rather than a data issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Secondly, from what I can tell, using the TO_TIMESTAMP function will apply the timezone for your session (which might not be the timezone you want).  I didn't realise this could be solved pretty easily by simply pasting your timezone to the end of the date string, like this;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TO_TIMESTAMP(MyDateTimeString || ' Timezone', 'M/d/y h:m:s a z)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;For example;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TO_TIMESTAMP(MyDateTimeString || ' America/Los_Angeles', 'M/d/y h:m:s a z)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 00:57:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-convert-string-to-datetime-with-correct-timezone/m-p/10745#M5844</guid>
      <dc:creator>najmead</dc:creator>
      <dc:date>2023-01-31T00:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to datetime with correct timezone?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-convert-string-to-datetime-with-correct-timezone/m-p/10746#M5845</link>
      <description>&lt;P&gt;use from_utc_timestamp(to_timestam("&amp;lt;string&amp;gt;", &amp;lt;format&amp;gt;),&amp;lt;timezone&amp;gt;)&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 11:48:45 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-convert-string-to-datetime-with-correct-timezone/m-p/10746#M5845</guid>
      <dc:creator>Rajeev_Basu</dc:creator>
      <dc:date>2023-02-03T11:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to datetime with correct timezone?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-convert-string-to-datetime-with-correct-timezone/m-p/10747#M5846</link>
      <description>&lt;P&gt;Use to_utc_timestamp(expr,timezone)​&lt;/P&gt;</description>
      <pubDate>Sat, 04 Feb 2023 14:30:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-convert-string-to-datetime-with-correct-timezone/m-p/10747#M5846</guid>
      <dc:creator>Manoj12421</dc:creator>
      <dc:date>2023-02-04T14:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to datetime with correct timezone?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-convert-string-to-datetime-with-correct-timezone/m-p/102858#M41251</link>
      <description>&lt;LI-CODE lang="markup"&gt;TO_DATE("12/30/2022 10:30:00 AM", "MM/dd/yyyy HH:mm:ss a") AS tsDate&lt;/LI-CODE&gt;&lt;P&gt;Is this correct if we need only date?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2024 18:18:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-convert-string-to-datetime-with-correct-timezone/m-p/102858#M41251</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2024-12-20T18:18:47Z</dc:date>
    </item>
  </channel>
</rss>

