This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- DateDiff function that returns the difference between two timestamps in the given date_part (weeks, months, etc) as an integer | |
-- This behaves like the DateDiff function in warehouses like Redshift and Snowflake, which count the boundaries between date_parts | |
CREATE OR REPLACE FUNCTION datediff (date_part VARCHAR(30), start_t TIMESTAMP, end_t TIMESTAMP) | |
RETURNS INT AS $diff$ | |
DECLARE | |
years INT = 0; | |
days INT = 0; | |
hours INT = 0; | |
minutes INT = 0; |