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.

INTERVAL_ADD_UDF
(INPUT_VALUE1 VARCHAR(), INPUT_PART1 VARCHAR(30), INPUT_VALUE2 VARCHAR(), INPUT_PART2 VARCHAR(30), OP CHAR, OUTPUT_PART VARCHAR())

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. I 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:

SELECT INTERVAL_ADD_UDF('7', 'HOUR', '1', 'HOUR', '+', 'HOUR');

Output:

8

Last updated