DATEDIFF_UDF (DATE, STRING)

Important Notice: Migration of Documentation Website

Please be advised that our documentation website is currently undergoing a migration to a new platform. To ensure you have access to the most up-to-date information, we kindly request that you visit our new documentation website located at:

Official Snowflake Snowconvert Documentation

For any immediate assistance or if you encounter any issues, please contact our support team at [email protected].

Thank you for your understanding.

Definition

This user-defined function (UDF) is used to generate the difference between an interval value and a date.

DATEDIFF_UDF(D DATE, INTERVAL_VALUE STRING)

Parameters

D DATE

The date to be used to process the difference with the interval.

INTERVAL_VALUE STRING

The interval value that will be used to create the difference from.

Returns

Returns a date with the resulting value of the subtraction of time.

Usage example

Input:

SELECT DATEDIFF_UDF('2024-01-30', 'INTERVAL ''2-1'' YEAR(2) TO MONTH');

Output:

2021-12-30

Last updated