TIMESTAMPDIFF
Returns the time span between two TIMESTAMP or TIMESTAMPTZ values, in the intervals specified. TIMESTAMPDIFF
excludes the start date in its calculation.
Behavior Type
Syntax
TIMESTAMPDIFF ( datepart, start, end );
Parameters
datepart |
Specifies the type of date or time intervals that TIMESTAMPDIFF((expression), start, end ); datepart must evaluate to one of the following string literals, either quoted or unquoted:
|
start, end
|
Specify the start and end dates, where start and end evaluate to one of the following data types:
If end < start, |
Date Part Intervals
TIMESTAMPDIFF
uses the datepart argument to calculate the number of intervals between two dates, rather than the actual amount of time between them. For detailed information, see DATEDIFF
.
Examples
=> SELECT TIMESTAMPDIFF (YEAR,'1-1-2006 12:34:00', '1-1-2008 12:34:00'); timestampdiff --------------- 2 (1 row)