diff --git a/splink/postgres/linker.py b/splink/postgres/linker.py index b8f0c94d90..3ec588174b 100644 --- a/splink/postgres/linker.py +++ b/splink/postgres/linker.py @@ -263,7 +263,7 @@ def _create_months_between_function(self): sql = f""" CREATE OR REPLACE FUNCTION ave_months_between(x date, y date) RETURNS float8 AS $$ - SELECT datediff(x, y)/{ave_length_month}; + SELECT (datediff(x, y)/{ave_length_month})::float8; $$ LANGUAGE SQL IMMUTABLE; """ self._run_sql_execution(sql) @@ -273,7 +273,7 @@ def _create_months_between_function(self): x {dateish_type}, y {dateish_type} ) RETURNS integer AS $$ - SELECT ave_months_between(DATE(x), DATE(y)); + SELECT (ave_months_between(DATE(x), DATE(y)))::int; $$ LANGUAGE SQL IMMUTABLE; """ for dateish_type in ("timestamp", "timestamp with time zone"):