<?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 date to integer in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/convert-date-to-integer/m-p/8093#M3813</link>
    <description>&lt;P&gt;I'd cast it to a unix timestamp.&lt;/P&gt;&lt;P&gt;&lt;A href="https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.functions.unix_timestamp.html" target="test_blank"&gt;https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.functions.unix_timestamp.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Mar 2023 12:51:24 GMT</pubDate>
    <dc:creator>-werners-</dc:creator>
    <dc:date>2023-03-09T12:51:24Z</dc:date>
    <item>
      <title>Convert date to integer</title>
      <link>https://community.databricks.com/t5/data-engineering/convert-date-to-integer/m-p/8092#M3812</link>
      <description>&lt;P&gt;Hello. Is there a way in Databricks sql to convert a date to integer? In Db2, there is days function &lt;A href="https://www.ibm.com/docs/pl/db2-for-zos/11?topic=functions-days" alt="https://www.ibm.com/docs/pl/db2-for-zos/11?topic=functions-days" target="_blank"&gt;DAYS - IBM Documentation&lt;/A&gt; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example '2023-03-01' is converted to 738580 value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 11:29:15 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/convert-date-to-integer/m-p/8092#M3812</guid>
      <dc:creator>elgeo</dc:creator>
      <dc:date>2023-03-08T11:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: Convert date to integer</title>
      <link>https://community.databricks.com/t5/data-engineering/convert-date-to-integer/m-p/8093#M3813</link>
      <description>&lt;P&gt;I'd cast it to a unix timestamp.&lt;/P&gt;&lt;P&gt;&lt;A href="https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.functions.unix_timestamp.html" target="test_blank"&gt;https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.functions.unix_timestamp.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 12:51:24 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/convert-date-to-integer/m-p/8093#M3813</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2023-03-09T12:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: Convert date to integer</title>
      <link>https://community.databricks.com/t5/data-engineering/convert-date-to-integer/m-p/8094#M3814</link>
      <description>&lt;P&gt;TRy this:&lt;/P&gt;&lt;P&gt;CREATE OR REPLACE FUNCTION days(dt DATE) RETURN unix_date(dt) - unix_date(DATE'0001-01-01') + 1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT current_date, days(current_date);&amp;nbsp;&lt;/P&gt;&lt;P&gt;2023-03-09	738588&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I verified on Db2 for LUW and it matches up. &lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 17:19:30 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/convert-date-to-integer/m-p/8094#M3814</guid>
      <dc:creator>SergeRielau</dc:creator>
      <dc:date>2023-03-09T17:19:30Z</dc:date>
    </item>
  </channel>
</rss>

