<?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 TIMEZONE in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/timezone/m-p/62008#M2768</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Can I get some help from Databricks to help me understand how those timestamps being interpreted? Some are really confusing me. I have timestamp coming into AWS Databricks as String type. And the string timestamp is represented in UTC. I ran below query in both UTC and CST cluster and I am trying to find the correct way to interpret the time. Thanks.select 'xxxx_cluster' as Cluster, EVENTTIME AS EVENTTIME_raw_string , to_timestamp(EVENTTIME) as test_1 , to_timestamp_ntz(EVENTTIME) as test_2 -- no timezone , to_timestamp(to_timestamp_ntz(EVENTTIME), 'Etc/UTC') as test_3 , to_timestamp(to_timestamp(EVENTTIME), 'Etc/UTC') as test_33 , to_timestamp(to_timestamp_ntz(EVENTTIME), 'America/Chicago') as test_4 , to_timestamp(to_timestamp(EVENTTIME), 'America/Chicago') as test_44 , to_utc_timestamp(to_timestamp_ntz(EVENTTIME), 'Etc/UTC') as test_5 , to_utc_timestamp(to_timestamp_ntz(EVENTTIME), 'America/Chicago') as test_6 , to_utc_timestamp(to_timestamp(EVENTTIME), 'Etc/UTC') as test_55 , to_utc_timestamp(to_timestamp(EVENTTIME), 'America/Chicago') as test_66 , from_utc_timestamp(to_timestamp_ntz(EVENTTIME), 'Etc/UTC') as test_7 , from_utc_timestamp(to_timestamp_ntz(EVENTTIME), 'America/Chicago') as test_8 , from_utc_timestamp(to_timestamp(EVENTTIME), 'Etc/UTC') as test_77 , from_utc_timestamp(to_timestamp(EVENTTIME), 'America/Chicago') as test_88&lt;SPAN&gt;e.g.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;to_timestamp(to_timestamp_ntz(EVENTTIME), 'Etc/UTC') as test_3 , to_timestamp(to_timestamp_ntz(EVENTTIME), 'America/Chicago') as test_4&lt;DIV class=""&gt;After doing all the test. I just found out that only these two kind of work for both CST and UTC cluster, which give me the correct result if the data comes in as string type timestamp. But I couldn't explain why is that.&lt;BR /&gt;For example. if my incoming string data is 2023-11-01 16:10:47&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;(UTC time) , I will get&lt;SPAN&gt;&amp;nbsp;2023-11-01T16:10:47Z&lt;SPAN&gt;&amp;nbsp;in UTC cluster and&lt;SPAN&gt;&amp;nbsp;2023-11-01T11:10:47-05:00&lt;SPAN&gt;&amp;nbsp;in CST cluster. which are correct using the above two functions, while others are not consistent in both clusters&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt;I also notice another thing. for function to_timestamp(to_timestamp_ntz(STRING_EVENTTIME), 'xxxxx')&amp;nbsp; no matter what timezone you put ( I tried&amp;nbsp;America/Los_Angeles&amp;nbsp;as well), it will give me correct result in both UTC and CST cluster. BUT, if you just do&amp;nbsp; to_timestamp(to_timestamp_ntz(EVENTTIME))&amp;nbsp;without putting anything there, it is not giving correct value.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Feb 2024 17:57:39 GMT</pubDate>
    <dc:creator>nan</dc:creator>
    <dc:date>2024-02-26T17:57:39Z</dc:date>
    <item>
      <title>TIMEZONE</title>
      <link>https://community.databricks.com/t5/get-started-discussions/timezone/m-p/62008#M2768</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Can I get some help from Databricks to help me understand how those timestamps being interpreted? Some are really confusing me. I have timestamp coming into AWS Databricks as String type. And the string timestamp is represented in UTC. I ran below query in both UTC and CST cluster and I am trying to find the correct way to interpret the time. Thanks.select 'xxxx_cluster' as Cluster, EVENTTIME AS EVENTTIME_raw_string , to_timestamp(EVENTTIME) as test_1 , to_timestamp_ntz(EVENTTIME) as test_2 -- no timezone , to_timestamp(to_timestamp_ntz(EVENTTIME), 'Etc/UTC') as test_3 , to_timestamp(to_timestamp(EVENTTIME), 'Etc/UTC') as test_33 , to_timestamp(to_timestamp_ntz(EVENTTIME), 'America/Chicago') as test_4 , to_timestamp(to_timestamp(EVENTTIME), 'America/Chicago') as test_44 , to_utc_timestamp(to_timestamp_ntz(EVENTTIME), 'Etc/UTC') as test_5 , to_utc_timestamp(to_timestamp_ntz(EVENTTIME), 'America/Chicago') as test_6 , to_utc_timestamp(to_timestamp(EVENTTIME), 'Etc/UTC') as test_55 , to_utc_timestamp(to_timestamp(EVENTTIME), 'America/Chicago') as test_66 , from_utc_timestamp(to_timestamp_ntz(EVENTTIME), 'Etc/UTC') as test_7 , from_utc_timestamp(to_timestamp_ntz(EVENTTIME), 'America/Chicago') as test_8 , from_utc_timestamp(to_timestamp(EVENTTIME), 'Etc/UTC') as test_77 , from_utc_timestamp(to_timestamp(EVENTTIME), 'America/Chicago') as test_88&lt;SPAN&gt;e.g.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;to_timestamp(to_timestamp_ntz(EVENTTIME), 'Etc/UTC') as test_3 , to_timestamp(to_timestamp_ntz(EVENTTIME), 'America/Chicago') as test_4&lt;DIV class=""&gt;After doing all the test. I just found out that only these two kind of work for both CST and UTC cluster, which give me the correct result if the data comes in as string type timestamp. But I couldn't explain why is that.&lt;BR /&gt;For example. if my incoming string data is 2023-11-01 16:10:47&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;(UTC time) , I will get&lt;SPAN&gt;&amp;nbsp;2023-11-01T16:10:47Z&lt;SPAN&gt;&amp;nbsp;in UTC cluster and&lt;SPAN&gt;&amp;nbsp;2023-11-01T11:10:47-05:00&lt;SPAN&gt;&amp;nbsp;in CST cluster. which are correct using the above two functions, while others are not consistent in both clusters&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt;I also notice another thing. for function to_timestamp(to_timestamp_ntz(STRING_EVENTTIME), 'xxxxx')&amp;nbsp; no matter what timezone you put ( I tried&amp;nbsp;America/Los_Angeles&amp;nbsp;as well), it will give me correct result in both UTC and CST cluster. BUT, if you just do&amp;nbsp; to_timestamp(to_timestamp_ntz(EVENTTIME))&amp;nbsp;without putting anything there, it is not giving correct value.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2024 17:57:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/timezone/m-p/62008#M2768</guid>
      <dc:creator>nan</dc:creator>
      <dc:date>2024-02-26T17:57:39Z</dc:date>
    </item>
  </channel>
</rss>

