

 Amazon Redshift will no longer support the use of Python UDFs after June 30, 2026. We will start enforcing it in phases. For more information on the details of Python end of life and migration options, see the [ blog post ](https://amazonaws-china.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/) that was published on June 30, 2025. 

# TIMESTAMPTZ\_CMP function
<a name="r_TIMESTAMPTZ_CMP"></a>

TIMESTAMPTZ\_CMP compares the value of two timestamp with time zone values and returns an integer. If the timestamps are identical, the function returns `0`. If the first timestamp is greater chronologically, the function returns `1`. If the second timestamp is greater, the function returns `–1`.

## Syntax
<a name="r_TIMESTAMPTZ_CMP-synopsis"></a>

```
TIMESTAMPTZ_CMP(timestamptz1, timestamptz2)
```

## Arguments
<a name="r_TIMESTAMPTZ_CMP-arguments"></a>

 *timestamptz1*   
A column of data type `TIMESTAMPTZ` or an expression that implicitly evaluates to a `TIMESTAMPTZ` type.

 *timestamptz2*   
A column of data type `TIMESTAMPTZ` or an expression that implicitly evaluates to a `TIMESTAMPTZ` type.

## Return type
<a name="r_TIMESTAMPTZ_CMP-return-type"></a>

INTEGER

## Examples
<a name="r_TIMESTAMPTZ_CMP-examples"></a>

The following example compares timestamps with time zones and shows the results of the comparison.

```
SELECT TIMESTAMPTZ_CMP('2008-01-24 06:43:29+00', '2008-01-24 06:43:29+00'), TIMESTAMPTZ_CMP('2008-01-24 06:43:29+00', '2008-02-18 02:36:48+00'), TIMESTAMPTZ_CMP('2008-02-18 02:36:48+00', '2008-01-24 06:43:29+00');

timestamptz_cmp  | timestamptz_cmp | timestamptz_cmp
-----------------+-----------------+----------------
        0        |       -1        |       1
```