SECONDS_BETWEEN

Purpose

This function returns the number of seconds between two timestamps.

Syntax

seconds_between::=

Usage notes

  • If a timestamp timestamp1 is earlier than timestamp timestamp2, then the result is negative.
  • Additionally, the result contains the difference in milliseconds.
  • For data type TIMESTAMP WITH LOCAL TIME ZONE this function is calculated internally within UTC.

Example

SELECT SECONDS_BETWEEN(TIMESTAMP '2000-01-01 12:01:02.345',
                       TIMESTAMP '2000-01-01 12:00:00') SB;