<?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 use dateadd in databricks sql ? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-use-dateadd-in-databricks-sql/m-p/19667#M13213</link>
    <description>&lt;P&gt;Beginning from Spark 3.0, you may use the&amp;nbsp;&lt;/P&gt;&lt;P&gt;make_interval(years, months, weeks, days, hours, mins, secs)&lt;/P&gt;&lt;P&gt;&amp;nbsp;function if you want to add intervals using values from other columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT &lt;/P&gt;&lt;P&gt;    id&lt;/P&gt;&lt;P&gt;    , Start_time + make_interval(0, 0, 0, 0, time_zone_offset, 0, 0) AS Local_Start_Time&lt;/P&gt;&lt;P&gt;FROM MyTable&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/60209203/adding-variable-hours-to-timestamp-in-spark-sql" target="test_blank"&gt;https://stackoverflow.com/questions/60209203/adding-variable-hours-to-timestamp-in-spark-sql&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 25 May 2022 20:27:01 GMT</pubDate>
    <dc:creator>alexa</dc:creator>
    <dc:date>2022-05-25T20:27:01Z</dc:date>
    <item>
      <title>How to use dateadd in databricks sql ?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-use-dateadd-in-databricks-sql/m-p/19666#M13212</link>
      <description>&lt;P&gt;I am trying to something like this but getting error like :&lt;/P&gt;&lt;P&gt;&lt;B&gt;Error in SQL statement: AnalysisException: Undefined function: 'DATEADD'. This function is neither a registered temporary function nor a permanent function registered in the database 'default'.&lt;/B&gt;&lt;/P&gt;&lt;P&gt;DATEADD(HOUR,IFNULL(Hours_Adjusted,0),Date_Created) AS  Date_Created_Local&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also tried, something like below but it seems interval doesn't support expression :&lt;/P&gt;&lt;P&gt;Date_Created+ INTERVAL Hours_Adjusted&amp;nbsp;hours AS Date_Created_Local&lt;/P&gt;&lt;P&gt;Please help me !!&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 16:19:28 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-use-dateadd-in-databricks-sql/m-p/19666#M13212</guid>
      <dc:creator>alexa</dc:creator>
      <dc:date>2022-05-25T16:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to use dateadd in databricks sql ?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-use-dateadd-in-databricks-sql/m-p/19667#M13213</link>
      <description>&lt;P&gt;Beginning from Spark 3.0, you may use the&amp;nbsp;&lt;/P&gt;&lt;P&gt;make_interval(years, months, weeks, days, hours, mins, secs)&lt;/P&gt;&lt;P&gt;&amp;nbsp;function if you want to add intervals using values from other columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT &lt;/P&gt;&lt;P&gt;    id&lt;/P&gt;&lt;P&gt;    , Start_time + make_interval(0, 0, 0, 0, time_zone_offset, 0, 0) AS Local_Start_Time&lt;/P&gt;&lt;P&gt;FROM MyTable&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/60209203/adding-variable-hours-to-timestamp-in-spark-sql" target="test_blank"&gt;https://stackoverflow.com/questions/60209203/adding-variable-hours-to-timestamp-in-spark-sql&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 20:27:01 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-use-dateadd-in-databricks-sql/m-p/19667#M13213</guid>
      <dc:creator>alexa</dc:creator>
      <dc:date>2022-05-25T20:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to use dateadd in databricks sql ?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-use-dateadd-in-databricks-sql/m-p/19668#M13214</link>
      <description>&lt;P&gt;&lt;A href="https://docs.databricks.com/spark/latest/spark-sql/language-manual/functions/dateadd.html" alt="https://docs.databricks.com/spark/latest/spark-sql/language-manual/functions/dateadd.html" target="_blank"&gt;Dateadd&lt;/A&gt; was added in DBR 10.4 and is in DBSQL current.&lt;/P&gt;&lt;P&gt;SELECT DATEADD(HOUR,IFNULL(100, 0),current_date) AS Date_Created_Local&lt;/P&gt;&lt;P&gt;=&amp;gt; 2022-05-31T04:00:00.000+0000.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also use one of these casts to turn any wellformed&lt;A href="https://docs.databricks.com/spark/latest/spark-sql/language-manual/functions/cast.html#string" alt="https://docs.databricks.com/spark/latest/spark-sql/language-manual/functions/cast.html#string" target="_blank"&gt; string into an interval&lt;/A&gt;:&lt;/P&gt;&lt;P&gt;SELECT current_date + 'INTERVAL \'100\' HOUR'::INTERVAL HOUR;&lt;/P&gt;&lt;P&gt;SELECT current_date + CAST ('INTERVAL \'100\' HOUR' AS INTERVAL HOUR);&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 14:11:23 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-use-dateadd-in-databricks-sql/m-p/19668#M13214</guid>
      <dc:creator>SergeRielau</dc:creator>
      <dc:date>2022-05-27T14:11:23Z</dc:date>
    </item>
  </channel>
</rss>

