<?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 2012-12-30 has year of both 2012 and 2013 sql in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/2012-12-30-has-year-of-both-2012-and-2013-sql/m-p/17330#M11357</link>
    <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I am trying to obtain the month and year in the format of "MM-YYY", then "YYY" to get a values such as 12-2012. I noticed an error where a timestamp of 2012-12-30T00:00:00.000+0000 results in both 12-2013 and 2013. This is an error, since 2012-12-30 is not the last day of that year, it is 2012-12-31. The correct result should be 12-2012 and 2013. I would like to know how to solve this error and what caused it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;My select statement is as such:&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;select Date,cast(Date as TIMESTAMP), 
&lt;P&gt;date_format(cast(Date as TIMESTAMP), 'MM-YYY'), &lt;/P&gt;
&lt;P&gt;date_format(cast(Date as TIMESTAMP), 'YYY')&lt;/P&gt;
&lt;P&gt; from SalesFactsDate1 &lt;/P&gt;
&lt;P&gt; where date_format(cast(Date as TIMESTAMP), 'YYY')=2012 &lt;/P&gt;
&lt;P&gt; or date_format(cast(Date as TIMESTAMP), 'YYY')=2013 &lt;/P&gt;
&lt;P&gt; order by Date&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;Date is in string format, but it can be cast as a timestamp 
&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Jul 2021 09:25:52 GMT</pubDate>
    <dc:creator>Josh21</dc:creator>
    <dc:date>2021-07-26T09:25:52Z</dc:date>
    <item>
      <title>2012-12-30 has year of both 2012 and 2013 sql</title>
      <link>https://community.databricks.com/t5/data-engineering/2012-12-30-has-year-of-both-2012-and-2013-sql/m-p/17330#M11357</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I am trying to obtain the month and year in the format of "MM-YYY", then "YYY" to get a values such as 12-2012. I noticed an error where a timestamp of 2012-12-30T00:00:00.000+0000 results in both 12-2013 and 2013. This is an error, since 2012-12-30 is not the last day of that year, it is 2012-12-31. The correct result should be 12-2012 and 2013. I would like to know how to solve this error and what caused it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;My select statement is as such:&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;select Date,cast(Date as TIMESTAMP), 
&lt;P&gt;date_format(cast(Date as TIMESTAMP), 'MM-YYY'), &lt;/P&gt;
&lt;P&gt;date_format(cast(Date as TIMESTAMP), 'YYY')&lt;/P&gt;
&lt;P&gt; from SalesFactsDate1 &lt;/P&gt;
&lt;P&gt; where date_format(cast(Date as TIMESTAMP), 'YYY')=2012 &lt;/P&gt;
&lt;P&gt; or date_format(cast(Date as TIMESTAMP), 'YYY')=2013 &lt;/P&gt;
&lt;P&gt; order by Date&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;Date is in string format, but it can be cast as a timestamp 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jul 2021 09:25:52 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/2012-12-30-has-year-of-both-2012-and-2013-sql/m-p/17330#M11357</guid>
      <dc:creator>Josh21</dc:creator>
      <dc:date>2021-07-26T09:25:52Z</dc:date>
    </item>
  </channel>
</rss>

