TIMESTAMP_DIFFERENCE_UDF
Last updated
Last updated
UDF That reproduces DATETIME Subtraction
Teradata and Snowflake handle date time subtraction different, the syntax, returned type and precision are different.
Syntax: The syntax used to handle DATE, TIMESTAMP and TIME subtraction operation in Teradata is with minus sign and interval used to specify the precision and format of operation result. For further details of syntax visit the following link . In Snowflake subtraction of DATE, TIMESTAMP and TIME are handled by three different functions, DATEDIFF, TIMESTAMPDIFF, and TIMEDIFF respectively, these operations takes 3 parameters, the dates, and the date part to be returned. Nevertheless, DATEDIFF function will work with TIMESTAMP and TIME types The minus sign can be used if the operation is with DATE type, in this case, the default return type is the number of days.
Return Type: In general the returned data type of Teradata are a different kind of Intervals. Intervals reference can be found at . The data type returned by Snowflake when one of the functions named above is called is Integer representing the number of units.
Rounding: To see when DATEDIFF (used in some cases UDF) uses the entire date or if it disregards of other parts in Snowflake visit the following link . This point could give different output than Teradata's
Some operations may produce different day outputs with an error range of 1 unit.
MINUEND
TIMSTAMP
Date subtracted from.
SUBTRAHEND
TIMESTAMP
Date subtracted.
INPUT_PART
VARCHAR
Parts to be returned.
Formatted string value according to the INPUT_PART
parameter.
Input
Output: