Menu
Amazon Redshift
Database Developer Guide (API Version 2012-12-01)

INTERVAL_CMP Function

INTERVAL_CMP compares two intervals and returns 1 if the first interval is greater, -1 if the second interval is greater, and 0 if the intervals are equal. For more information, see Interval Literals.

Syntax

Copy
INTERVAL_CMP(interval1, interval2)

Arguments

interval1

An interval literal value.

interval2

An interval literal value.

Return Type

INTEGER

Examples

The following example compares the value of "3 days" to "1 year":

Copy
select interval_cmp('3 days','1 year'); interval_cmp -------------- -1

This example compares the value "7 days" to "1 week":

Copy
select interval_cmp('7 days','1 week'); interval_cmp -------------- 0 (1 row)