UDF: Month of Year

UDF: Month of Year

Description

This UDF will take a DATE and return the month of year (e.g. “January”) as a STRING.

CREATE OR REPLACE FUNCTION <DATASET>.month_of_year(dt DATE) RETURNS STRING AS
(
FORMAT_DATE('%B',dt)
);```

## Example (optional)
```sql
with data as (
    select dates from unnest(generate_date_array('2021-02-28', '2021-03-02', INTERVAL 1 DAY)) AS dates
)
select 
    dates, 
    spotify.month_of_year(dates) month_of_year
from data
dates month_of_year
2021-02-28 February
2021-03-01 March
2021-03-02 March