forked from dbt-labs/dbt-utils
-
Notifications
You must be signed in to change notification settings - Fork 3
/
dateadd.sql
31 lines (19 loc) · 788 Bytes
/
dateadd.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
{% macro dateadd(datepart, interval, from_date_or_timestamp) %}
{{ adapter_macro('dbt_utils_sqlserver.dateadd', datepart, interval, from_date_or_timestamp) }}
{% endmacro %}
{% macro default__dateadd(datepart, interval, from_date_or_timestamp) %}
dateadd(
{{ datepart }},
{{ interval }},
{{ from_date_or_timestamp }}
)
{% endmacro %}
{% macro bigquery__dateadd(datepart, interval, from_date_or_timestamp) %}
datetime_add(
cast( {{ from_date_or_timestamp }} as datetime),
interval {{ interval }} {{ datepart }}
)
{% endmacro %}
{% macro postgres__dateadd(datepart, interval, from_date_or_timestamp) %}
{{ from_date_or_timestamp }} + ((interval '1 {{ datepart }}') * ({{ interval }}))
{% endmacro %}