title: How to get week of year in spark 3.0+?
body: <p>I'm trying to create a calendar file with columns for day, month, etc. The following code works fine, but I couldn't find a clean way to extract the week of year (1-52). In <code>spark 3.0+</code>, the following line of code doesn't work: <code>.withColumn(&quot;week_of_year&quot;, date_format(col(&quot;day_id&quot;), &quot;W&quot;))</code></p>
  <p>I know that I can create a view/table and then run a SQL query on it to extract the <code>week_of_year</code>, but is there no better way to do it?
  `</p>
  <pre><code>df.withColumn(&quot;day_id&quot;, to_date(col(&quot;day_id&quot;), date_fmt))
  .withColumn(&quot;week_day&quot;, date_format(col(&quot;day_id&quot;), &quot;EEEE&quot;))
  .withColumn(&quot;month_of_year&quot;, date_format(col(&quot;day_id&quot;), &quot;M&quot;))
  .withColumn(&quot;year&quot;, date_format(col(&quot;day_id&quot;), &quot;y&quot;))
  .withColumn(&quot;day_of_month&quot;, date_format(col(&quot;day_id&quot;), &quot;d&quot;))
  .withColumn(&quot;quarter_of_year&quot;, date_format(col(&quot;day_id&quot;), &quot;Q&quot;))
  </code></pre>