Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

INTERVAL_CMP function

Focus mode
INTERVAL_CMP function - Amazon Redshift

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 Examples of interval literals without qualifier syntax.

Syntax

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.

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

This example compares the value 7 days to 1 week.

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

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

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

On this page

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.