-
-
Notifications
You must be signed in to change notification settings - Fork 65
/
month_name.sql
43 lines (35 loc) · 1.21 KB
/
month_name.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{%- macro month_name(date, short=True) -%}
{{ adapter.dispatch('month_name', 'dbt_date') (date, short) }}
{%- endmacro %}
{%- macro default__month_name(date, short) -%}
{%- set f = 'MON' if short else 'MONTH' -%}
to_char({{ date }}, '{{ f }}')
{%- endmacro %}
{%- macro bigquery__month_name(date, short) -%}
{%- set f = '%b' if short else '%B' -%}
format_date('{{ f }}', cast({{ date }} as date))
{%- endmacro %}
{%- macro snowflake__month_name(date, short) -%}
{%- set f = 'MON' if short else 'MMMM' -%}
to_char({{ date }}, '{{ f }}')
{%- endmacro %}
{%- macro postgres__month_name(date, short) -%}
{# FM = Fill mode, which suppresses padding blanks #}
{%- set f = 'FMMon' if short else 'FMMonth' -%}
to_char({{ date }}, '{{ f }}')
{%- endmacro %}
{%- macro duckdb__month_name(date, short) -%}
{%- if short -%}
substr(monthname({{ date }}), 1, 3)
{%- else -%}
monthname({{ date }})
{%- endif -%}
{%- endmacro %}
{%- macro spark__month_name(date, short) -%}
{%- set f = 'MMM' if short else 'MMMM' -%}
date_format({{ date }}, '{{ f }}')
{%- endmacro %}
{%- macro trino__month_name(date, short) -%}
{%- set f = 'b' if short else 'M' -%}
date_format({{ date }}, '%{{ f }}')
{%- endmacro %}