diff --git a/dbt/include/spark/macros/utils/datediff.sql b/dbt/include/spark/macros/utils/datediff.sql index d0e684c47..5eeb0281a 100644 --- a/dbt/include/spark/macros/utils/datediff.sql +++ b/dbt/include/spark/macros/utils/datediff.sql @@ -73,12 +73,12 @@ {%- endset -%} case when {{first_date}} < {{second_date}} - then ceil(( + then floor(( {# make sure the timestamps are real, otherwise raise an error asap #} {{ assert_not_null('to_unix_timestamp', assert_not_null('to_timestamp', second_date)) }} - {{ assert_not_null('to_unix_timestamp', assert_not_null('to_timestamp', first_date)) }} ) / {{divisor}}) - else floor(( + else ceil(( {{ assert_not_null('to_unix_timestamp', assert_not_null('to_timestamp', second_date)) }} - {{ assert_not_null('to_unix_timestamp', assert_not_null('to_timestamp', first_date)) }} ) / {{divisor}}) @@ -105,3 +105,4 @@ {%- endif -%} {% endmacro %} +