<?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 Convert Week of Year to Month in SQL? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/convert-week-of-year-to-month-in-sql/m-p/29868#M21564</link>
    <description>&lt;P&gt;Hi all, &lt;/P&gt;&lt;P&gt;Was wondering if there was any built in function or code that I could utilize to convert a singular week of year integer (i.e. 1 to 52), into a value representing month (i.e. 1-12)? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The assumption is that a week start on a Monday and end on a Sunday.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 02 Feb 2022 16:25:58 GMT</pubDate>
    <dc:creator>ST</dc:creator>
    <dc:date>2022-02-02T16:25:58Z</dc:date>
    <item>
      <title>Convert Week of Year to Month in SQL?</title>
      <link>https://community.databricks.com/t5/data-engineering/convert-week-of-year-to-month-in-sql/m-p/29868#M21564</link>
      <description>&lt;P&gt;Hi all, &lt;/P&gt;&lt;P&gt;Was wondering if there was any built in function or code that I could utilize to convert a singular week of year integer (i.e. 1 to 52), into a value representing month (i.e. 1-12)? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The assumption is that a week start on a Monday and end on a Sunday.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 16:25:58 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/convert-week-of-year-to-month-in-sql/m-p/29868#M21564</guid>
      <dc:creator>ST</dc:creator>
      <dc:date>2022-02-02T16:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Week of Year to Month in SQL?</title>
      <link>https://community.databricks.com/t5/data-engineering/convert-week-of-year-to-month-in-sql/m-p/29869#M21565</link>
      <description>&lt;P&gt;we need old parser as new doesn't support weeks. Than we can map what we need using w - year of year and u - first day of the week:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;spark.sql("set spark.sql.legacy.timeParserPolicy=LEGACY")
spark.sql("""
SELECT 
    extract(
        month from to_date("2022-12-1", "y-w-u")
     ) as month_of_year
 """)&lt;/CODE&gt;&lt;/PRE&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/2142i609E30548A6155EB/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, 02 Feb 2022 19:41:58 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/convert-week-of-year-to-month-in-sql/m-p/29869#M21565</guid>
      <dc:creator>Hubert-Dudek</dc:creator>
      <dc:date>2022-02-02T19:41:58Z</dc:date>
    </item>
  </channel>
</rss>

