Skip to content

Commit

Permalink
Changed Macro
Browse files Browse the repository at this point in the history
  • Loading branch information
JumboDVDH0 committed May 30, 2024
1 parent 1df0d35 commit 317e12d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions macros/select_date_range.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% macro select_date_range(start_date, end_date, date_column) %}
{% if start_date is not none and end_date is not none %}
REPLACE(CAST({{date_column}} AS STRING), "-", "") >= CAST({{ start_date }} AS STRING) and REPLACE(CAST({{date_column}} AS STRING), "-", "") <= CAST({{ end_date }} AS STRING)
CAST({{ date_column }} AS DATE) BETWEEN DATE '{{ start_date }}' AND DATE '{{ end_date }}'
{% else %}
{{ date_column }} >= CURRENT_DATE - {{ var("lookback_window") }}
CAST({{ date_column }} AS DATE) >= CURRENT_DATE() - INTERVAL {{ var("lookback_window") }} DAY
{% endif %}
{% endmacro %}
{% endmacro %}

0 comments on commit 317e12d

Please sign in to comment.