forked from dbt-labs/dbt-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatediff.sql
More file actions
32 lines (20 loc) · 729 Bytes
/
datediff.sql
File metadata and controls
32 lines (20 loc) · 729 Bytes
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
{% macro datediff(first_date, second_date, datepart) %}
{{ adapter_macro('dbt_utils.datediff', first_date, second_date, datepart) }}
{% endmacro %}
{% macro default__datediff(first_date, second_date, datepart) %}
datediff(
{{ datepart }},
{{ first_date }},
{{ second_date }}
)
{% endmacro %}
{% macro bigquery__datediff(first_date, second_date, datepart) %}
datetime_diff(
cast({{second_date}} as datetime),
cast({{first_date}} as datetime),
{{datepart}}
)
{% endmacro %}
{% macro postgres__datediff(first_date, second_date, datepart) %}
{{ exceptions.raise_compiler_error("macro datediff not implemented for this adapter") }}
{% endmacro %}