diff --git a/macros/select_date_range.sql b/macros/select_date_range.sql index 8dabf6ad..783f2b4e 100644 --- a/macros/select_date_range.sql +++ b/macros/select_date_range.sql @@ -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 %} \ No newline at end of file