Return the memory size in bytes
memSize(ttype) → integer
SELECT memSize(tint '{1@2001-01-01, 2@2001-01-02, 3@2001-01-03}');
-- 176
Return the temporal type
tempSubtype(ttype) → {'Instant','Sequence','SequenceSet'}
SELECT tempSubtype(tint '[1@2001-01-01, 2@2001-01-02, 3@2001-01-03]'); -- Sequence
Return the interpolation
interp(ttype) → {'None','Discrete','Step','Linear'}
SELECT interp(tbool 'true@2001-01-01');
-- None
SELECT interp(tfloat '{1@2001-01-01, 2@2001-01-02, 3@2001-01-03}');
-- Discrete
SELECT interp(tint '[1@2001-01-01, 2@2001-01-02, 3@2001-01-03]');
-- Step
SELECT interp(tfloat '[1@2001-01-01, 2@2001-01-02, 3@2001-01-03]');
-- Linear
SELECT interp(tfloat 'Interp=Step;[1@2001-01-01, 2@2001-01-02, 3@2001-01-03]');
-- Step
SELECT interp(tgeompoint 'Interp=Step;[Point(1 1)@2001-01-01,
Point(2 2)@2001-01-02, Point(3 3)@2001-01-03]');
-- Step
SELECT interp(tgeometry '[Point(1 1)@2001-01-01,
Linestring(1 1,2 2)@2001-01-02, Polygon((3 3,4 4,5 3,3 3))@2001-01-03]');
-- Step
Return the value or the timestamp of an instant
getValue(ttypeInst) → base
getTimestamp(ttypeInst) → timestamptz
SELECT getValue(tint '1@2001-01-01'); -- 1 SELECT getTimestamp(tfloat '1@2001-01-01'); -- 2001-01-01
Return the values or the time on which a temporal value is defined
getValues(ttype) → baseset
getTime(ttype) → tstzspanset
SELECT getValues(tbool '[false@2001-01-01, true@2001-01-02, false@2001-01-03]');
-- {f,t}
SELECT getValues(tint '[1@2001-01-01, 3@2001-01-02, 1@2001-01-03]');
-- {[1, 2), [3, 4)}
SELECT getValues(tint '{[1@2001-01-01, 2@2001-01-02, 1@2001-01-03],
[4@2001-01-04, 4@2001-01-05]}');
-- {[1, 3), [4, 5)}
SELECT getValues(tfloat '{1@2001-01-01, 2@2001-01-02, 1@2001-01-03}');
-- {[1, 1], [2, 2]}
SELECT getValues(tfloat 'Interp=Step;{[1@2001-01-01, 2@2001-01-02, 1@2001-01-03],
[3@2001-01-04, 3@2001-01-05]}');
-- {[1, 1], [2, 2], [3, 3]}
SELECT getValues(tfloat '[1@2001-01-01, 2@2001-01-02, 1@2001-01-03]');
-- {[1, 2]}
SELECT getValues(tfloat '{[1@2001-01-01, 2@2001-01-02, 1@2001-01-03],
[3@2001-01-04, 3@2001-01-05]}');
-- {[1, 2], [3, 3]}
SELECT getTime(ttext 'walking@2001-01-01');
-- {[2001-01-01, 2001-01-01]}
SELECT getTime(tfloat '{1@2001-01-01, 2@2001-01-02, 1@2001-01-03}');
-- {[2001-01-01, 2001-01-01], [2001-01-02, 2001-01-02], [2001-01-03, 2001-01-03]}
SELECT getTime(tint '[1@2001-01-01, 1@2001-01-15)');
-- {[2001-01-01, 2001-01-15)}
SELECT getTime(tfloat '{[1@2001-01-01, 1@2001-01-10), [12@2001-01-12, 12@2001-01-15]}');
-- {[2001-01-01, 2001-01-10), [2001-01-12, 2001-01-15]}
Return the start, end, or n-th value
startValue(ttype) → base
endValue(ttype) → base
valueN(ttype,int) → base
The functions do not take into account whether the bounds are inclusive or not.
SELECT startValue(tfloat '(1@2001-01-01, 2@2001-01-03)');
-- 1
SELECT endValue(tfloat '{[1@2001-01-01, 2@2001-01-03), [3@2001-01-03, 5@2001-01-05)}');
-- 5
SELECT valueN(tfloat '{[1@2001-01-01, 2@2001-01-03), [3@2001-01-03, 5@2001-01-05)}', 3);
-- 3
Return the value at a timestamp
valueAtTimestamp(ttype,timestamptz) → base
SELECT valueAtTimestamp(tfloat '[1@2001-01-01, 4@2001-01-04)', '2001-01-02'); -- 2
Return the time interval
duration(ttype,boundspan=false) → interval
An additional parameter can be set to true to compute the duration of the bounding time span, thus ignoring the potential time gaps
SELECT duration(tfloat '{1@2001-01-01, 2@2001-01-03, 2@2001-01-05}');
-- 00:00:00
SELECT duration(tfloat '{1@2001-01-01, 2@2001-01-03, 2@2001-01-05}', true);
-- 4 days
SELECT duration(tfloat '[1@2001-01-01, 2@2001-01-03, 2@2001-01-05)');
-- 4 days
SELECT duration(tfloat '{[1@2001-01-01, 2@2001-01-03), [2@2001-01-04, 2@2001-01-05)}');
-- 3 days
SELECT duration(tfloat '{[1@2001-01-01, 2@2001-01-03), [2@2001-01-04, 2@2001-01-05)}',
true);
-- 4 days
Is the start/end instant inclusive?
lowerInc(ttype) → bool
upperInc(ttype) → bool
SELECT lowerInc(tint '[1@2001-01-01, 2@2001-01-02)');
-- true
SELECT upperInc(tfloat '{[1@2001-01-01, 2@2001-01-02), (2@2001-01-02, 3@2001-01-03)}');
-- false
Return the (number of) different instants
numInstants(ttype) → integer
instants(ttype) → ttypeInst[]
SELECT numInstants(tfloat '{[1@2001-01-01, 2@2001-01-02), (2@2001-01-02, 3@2001-01-03)}');
-- 3
SELECT instants(tfloat '{[1@2001-01-01, 2@2001-01-02), (2@2001-01-02, 3@2001-01-03)}');
-- {"1@2001-01-01","2@2001-01-02","3@2001-01-03"}
Return the start, end, or n-th instant
startInstant(ttype) → ttypeInst
endInstant(ttype) → ttypeInst
instantN(ttype,integer) → ttypeInst
The functions do not take into account whether the bounds are inclusive or not.
SELECT startInstant(tfloat '{[1@2001-01-01, 2@2001-01-02),
(2@2001-01-02, 3@2001-01-03)}');
-- 1@2001-01-01
SELECT endInstant(tfloat '{[1@2001-01-01, 2@2001-01-02), (2@2001-01-02, 3@2001-01-03)}');
-- 3@2001-01-03
SELECT instantN(tfloat '{[1@2001-01-01, 2@2001-01-02), (2@2001-01-02, 3@2001-01-03)}', 3);
-- 3@2001-01-03
Return the (number of) different timestamps
numTimestamps(ttype) → integer
timestamps(ttype) → timestamptz[]
SELECT numTimestamps(tfloat '{[1@2001-01-01, 2@2001-01-03),
[3@2001-01-03, 5@2001-01-05)}');
-- 3
SELECT timestamps(tfloat '{[1@2001-01-01, 2@2001-01-03), [3@2001-01-03, 5@2001-01-05)}');
-- {"2001-01-01", "2001-01-03", "2001-01-05"}
Return the start, end, or n-th timestamp
startTimestamp(ttype) → timestamptz
endTimestamp(ttype) → timestamptz
timestampN(ttype,integer) → timestamptz
The functions do not take into account whether the bounds are inclusive or not.
SELECT startTimestamp(tfloat '[1@2001-01-01, 2@2001-01-03)');
-- 2001-01-01
SELECT endTimestamp(tfloat '{[1@2001-01-01, 2@2001-01-03),
[3@2001-01-03, 5@2001-01-05)}');
-- 2001-01-05
SELECT timestampN(tfloat '{[1@2001-01-01, 2@2001-01-03),
[3@2001-01-03, 5@2001-01-05)}', 3);
-- 2001-01-05
Return the (number of) sequences
numSequences({ttypeContSeq,ttypeSeqSet}) → integer
sequences({ttypeContSeq,ttypeSeqSet}) → ttypeContSeq[]
SELECT numSequences(tfloat '{[1@2001-01-01, 2@2001-01-03),
[3@2001-01-03, 5@2001-01-05)}');
-- 2
SELECT sequences(tfloat '{[1@2001-01-01, 2@2001-01-03), [3@2001-01-03, 5@2001-01-05)}');
-- {"[1@2001-01-01, 2@2001-01-03)", "[3@2001-01-03, 5@2001-01-05)"}
Return the start, end, or n-th sequence
startSequence({ttypeContSeq,ttypeSeqSet}) → ttypeContSeq
endSequence({ttypeContSeq,ttypeSeqSet}) → ttypeContSeq
sequenceN({ttypeContSeq,ttypeSeqSet},integer) → ttypeContSeq
SELECT startSequence(tfloat '{[1@2001-01-01, 2@2001-01-03),
[3@2001-01-03, 5@2001-01-05)}');
-- [1@2001-01-01, 2@2001-01-03)
SELECT endSequence(tfloat '{[1@2001-01-01, 2@2001-01-03), [3@2001-01-03, 5@2001-01-05)}');
-- [3@2001-01-03, 5@2001-01-05)
SELECT sequenceN(tfloat '{[1@2001-01-01, 2@2001-01-03),
[3@2001-01-03, 5@2001-01-05)}', 2);
-- [3@2001-01-03, 5@2001-01-05)
Return the segments
segments({ttypeContSeq,ttypeSeqSet}) → ttypeContSeq[]
SELECT segments(tint '{[1@2001-01-01, 3@2001-01-02, 2@2001-01-03],
(3@2001-01-03, 5@2001-01-05]}');
/* {"[1@2001-01-01, 1@2001-01-02)","[3@2001-01-02, 3@2001-01-03)","[2@2001-01-03]",
"(3@2001-01-03, 3@2001-01-05)","[5@2001-01-05]"} */
SELECT segments(tfloat '{[1@2001-01-01, 3@2001-01-02, 2@2001-01-03],
(3@2001-01-03, 5@2001-01-05]}');
/* {"[1@2001-01-01, 3@2001-01-02)","[3@2001-01-02, 2@2001-01-03]",
"(3@2001-01-03, 5@2001-01-05]"} */