SnowConvert AI - Function References - Shared¶
INTERVAL_ MULTIPLY_ UDF (VARCHAR, VARCHAR, INTEGER)¶
Definition¶
This user-defined function (UDF) is used to multiply a time interval by a factor of N.
Parameters¶
INPUT_PART VARCHAR
The format of the operation. E.g.: DAY, HOUR TO SECOND, YEAR TO MONTH.
INPUT_VALUE VARCHAR
The interval of time to be multiplied.
INPUT_MULT INTEGER
The time to multiply the interval of time.
Returns¶
Returns a varchar with the result of the multiplication.
Usage example¶
Input:
Output:
TRUNC_ UDF (TIMESTAMP_ LTZ, VARCHAR)¶
Definition¶
This user-defined function (UDF) reproduces the Teradata and Oracle TRUNC(Date) functionality when the format parameter is specified.
Parameters¶
DATE_TO_TRUNC TIMESTAMP_LTZ
A timestamp_ltz value to truncate which must be a date, timestamp, or timestamp with timezone.
DATE_FMT VARCHAR
A varchar value that should be one of the date formats supported by the trunc function.
Returns¶
Returns a date truncated using the format specified.
Usage example¶
Input:
Output:
INTERVAL_ TO_ SECONDS_ UDF (VARCHAR, VARCHAR)¶
Definition¶
This user-defined function (UDF) is used to determine the quantity of seconds from an interval which is also correlated to the processed time type. This is an auxiliary function.
Parameters¶
INPUT_PART VARCHAR
The related type of the second parameter. E.g. DAY, DAY TO HOUR, HOUR, MINUTE.
INPUT_VALUE VARCHAR
The value to be converted to seconds.
Returns¶
Returns a decimal value type with the number of seconds.
Usage example¶
Input:
Output:
DATEDIFF_ UDF (DATE, STRING)¶
Definition¶
This user-defined function (UDF) is used to generate the difference between an interval value and a date.
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:
Output:
SECONDS_ TO_ INTERVAL_ UDF (VARCHAR, NUMBER)¶
Definition¶
This user-defined function (UDF) is used to transform seconds into intervals. This is an auxiliary function.
Parameters¶
INPUT_PART VARCHAR
The related type of the second parameter. E.g. DAY, DAY TO HOUR, HOUR, MINUTE, MINUTE TO SECOND.
INPUT_VALUE VARCHAR
The seconds to be converted to intervals.
Returns¶
Returns
Usage example¶
Input:
Output:
DATEADD_ UDF (STRING, DATE)¶
Definition¶
This user-defined function (UDF) is used to add a date with an interval of time.
Parameters¶
INTERVAL_VALUE STRING
The interval of time to be added.
D DATE
The date to be added with the interval of time.
Returns¶
Returns a date with the addition of the interval of time and the date.
Usage example¶
Input:
Output:
DATEDIFF_ UDF (STRING, DATE)¶
Definition¶
This user-defined function (UDF) is used to generate the difference between an interval value and a date.
Parameters¶
INTERVAL_VALUE STRING
The interval value that will be used to create the difference from.
D DATE
The date to be used to process the difference with the interval.
Returns¶
Returns a date with the resulting value of the subtraction of time.
Usage example¶
Input:
Output:
DATEADD_ UDF (DATE, STRING)¶
Definition¶
This user-defined function (UDF) is used to add a date with an interval of time.
Parameters¶
D DATE
The date to be added with the interval of time.
INTERVAL_VALUE STRING
The interval of time to be added.
Returns¶
Returns a date with the addition of the interval of time and the date.
Usage example¶
Input:
Output:
TO_ INTERVAL_ UDF (TIME)¶
Definition¶
This user-defined function (UDF) is used to generate a separate interval of time from the current time.
Parameters¶
D2 TIME
The input time to converts into a separate interval.
Returns¶
Returns a string with the information of the input time separated.
Usage example¶
Input:
Output:
INTERVAL_ TO_ MONTHS_ UDF (VARCHAR)¶
Definition¶
This user-defined function (UDF) is used to generate an integer with the quantity of a month from an interval. This is an auxiliary function.
Parameters¶
INPUT_VALUE VARCHAR
The interval value to be transformed into months.
Returns¶
Returns an integer with the processed information about months.
Usage example¶
Input:
Output:
DATEDIFF_ UDF (STRING, TIMESTAMP)¶
Definition¶
This user-defined function (UDF) is used to subtract an interval of time with a timestamp.
Parameters¶
INTERVAL_VALUE STRING
The interval of time to be subtracted.
D TIMESTAMP
The timestamp to be subtracted with the interval of time.
Returns¶
Returns a date with the subtraction of the interval of time and the date.
Usage example¶
Input:
Output:
MONTHS_ TO_ INTERVAL_ UDF (VARCHAR, NUMBER)¶
Definition¶
This user-defined function (UDF) is used to transform month values to intervals. This is an auxiliary function.
Parameters¶
INPUT_PART VARCHAR
The related type of the second parameter. E.g. YEAR TO MONTH, YEAR, MONTH.
INPUT_VALUE VARCHAR
The month to be converted to intervals.
Returns¶
Returns a varchar with the input value transform to an interval.
Usage example¶
Input:
Output:
DATEDIFF_ UDF (TIMESTAMP, STRING)¶
Definition¶
This user-defined function (UDF) is used to subtract a timestamp with an interval of time.
Parameters¶
D TIMESTAMP
The timestamp that will be subtracted with the interval of time.
INTERVAL_VALUE STRING
The interval of time to be subtracted.
Returns¶
Returns a date with the subtraction of the interval of time and the date.
Usage example¶
Input:
Output:
TRUNC_ UDF (NUMBER)¶
Definition¶
This user-defined function (UDF) reproduces the Teradata and Oracle TRUNC(Numeric) functionality when a scale is not specified.
Parameters¶
INPUT NUMBER
The number to truncate.
Returns¶
Returns an int as the input truncated to zero decimal places.
Usage example¶
Input:
Output:
TRUNC_ UDF (NUMBER, NUMBER)¶
Definition¶
This user-defined function (UDF) reproduces the Teradata and Oracle TRUNC(Numeric) functionality when a scale is specified.
Parameters¶
INPUT NUMBER
The number to truncate.
SCALE NUMBER
The amount of places to truncate (between -38 and 38).
Returns¶
Returns an int as the input truncated to scale places.
Usage example¶
Input:
Output:
INTERVAL_ ADD_ UDF (VARCHAR, VARCHAR, VARCHAR, VARCHAR, CHAR, VARCHAR)¶
Definition¶
This user-defined function (UDF) is used to add or subtract intervals with a specific time type.
Parameters¶
INPUT_VALUE1 VARCHAR
The quantity referenced to a time type.
INPUT_PART1 VARCHAR
The time type of the INPUT_VALUE1. E.g.: HOUR.
INPUT_VALUE2 VARCHAR
The second quantity referenced to a time type.
INPUT_PART2 VARCHAR
The time type of the INPUT_VALUE2. E.g.: HOUR.
OP CHAR
The operation. It can be a ‘+’ or a ‘-’.
OUTPUT_PART VARCHAR
The time type of the output operation.
Returns¶
Returns a varchar with the result of the indicated operation and values.
Usage example¶
Input:
Output:
DATEADD_ UDF (STRING, TIMESTAMP)¶
Definition¶
This user-defined function (UDF) is used to add a timestamp with an interval of time.
Parameters¶
INTERVAL_VALUE STRING
The interval of time to be added.
D TIMESTAMP
The timestamp to be added with the interval of time.
Returns¶
Returns a date with the addition of the interval of time and the date.
Usage example¶
Input:
Output:
TRUNC_ UDF (TIMESTAMP_ LTZ)¶
Definition¶
This user-defined function (UDF) reproduces the Teradata and Oracle TRUNC(Date) functionality when the format parameter is not specified.
Parameters¶
DATE_TO_TRUNC TIMESTAMP_LTZ
A timestamp_ltz value to truncate which must be a date, timestamp, or timestamp with timezone.
Returns¶
Returns a date part of DATE_TO_TRUNC.
Usage example¶
Input:
Output:
DATEADD_ UDF (TIMESTAMP, STRING)¶
Definition¶
This user-defined function (UDF) is used to add a timestamp with an interval of time.
Parameters¶
D TIMESTAMP
The timestamp to be added with the interval of time.
INTERVAL_VALUE STRING
The interval of time to be added.
Returns¶
Returns a date with the addition of the interval of time and the date.
Usage example¶
Input:
Output:
LOG_ INFO_ UDP (VARCHAR)¶
Definition¶
This user-defined store procedure (UDP) is used to log messages using the Snowflake SYSTEM$LOG functions.
Parameters¶
MESSAGE VARCHAR
The message to be logged.
Returns¶
A success message indicating the log operation was completed.
Usage example¶
Input:
Output:
| RESULT |
|---|
| ‘Message logged successfully’ |