Temporal addition
{number,tnumber} + {number,tnumber}: tnumber
SELECT tint '[2@2012-01-01, 2@2012-01-04)' + 1.5; -- "[3.5@2012-01-01, 3.5@2012-01-04)" SELECT tint '[2@2012-01-01, 2@2012-01-04)' + tfloat '[1@2012-01-01, 4@2012-01-04)'; -- "[3@2012-01-01, 6@2012-01-04)" SELECT tfloat '[1@2012-01-01, 4@2012-01-04)' + tfloat '{[1@2012-01-01, 2@2012-01-02), [1@2012-01-02, 2@2012-01-04)}'; -- "{[2@2012-01-01, 4@2012-01-04), [3@2012-01-02, 6@2012-01-04)}"
Temporal subtraction
{number,tnumber} - {number,tnumber}: tnumber
SELECT tint '[1@2012-01-01, 1@2012-01-04)' - tint '[2@2012-01-03, 2@2012-01-05)'; -- "[-1@2012-01-03, -1@2012-01-04)" SELECT tfloat '[3@2012-01-01, 6@2012-01-04)' - tint '[2@2012-01-01, 2@2012-01-04)'; -- "[1@2012-01-01, 4@2012-01-04)"
Temporal multiplication
{number,tnumber} * {number,tnumber}: tnumber
SELECT tfloat '[1@2012-01-01, 4@2012-01-04)' * 2; -- "[2@2012-01-01, 8@2012-01-04)" SELECT tfloat '[1@2012-01-01, 4@2012-01-04)' * tint '[2@2012-01-01, 2@2012-01-04)'; -- "[2@2012-01-01, 8@2012-01-04)" SELECT tfloat '[1@2012-01-01, 3@2012-01-03)' * '[3@2012-01-01, 1@2012-01-03)' -- "{[3@2012-01-01, 4@2012-01-02, 3@2012-01-03)}"
Temporal division
{number,tnumber} / {number,tnumber}: tnumber
The function will raise an error if the denominator will ever be equal to zero during the common timespan of the arguments.
SELECT 2 / tfloat '[1@2012-01-01, 3@2012-01-04)'; -- "[2@2012-01-01, 1@2012-01-02 12:00:00+00, 0.666666666666667@2012-01-04)" SELECT tfloat '[1@2012-01-01, 5@2012-01-05)' / '[5@2012-01-01, 1@2012-01-05)' -- "{[0.2@2012-01-01, 1@2012-01-03,2012-01-03, 5@2012-01-03,2012-01-05)}" SELECT 2 / tfloat '[-1@2000-01-01, 1@2000-01-02]' -- ERROR: Division by zero SELECT tfloat '[-1@2000-01-04, 1@2000-01-05]' / tfloat '[-1@2000-01-01, 1@2000-01-05]' -- "[-2@2000-01-04, 1@2000-01-05]"
Round the values to a number of decimal places
round(tfloat,integer): tfloat
SELECT round(tfloat '[0.785398163397448@2000-01-01, 2.35619449019234@2000-01-02]', 2); -- "[0.79@2000-01-01, 2.36@2000-01-02]"
Convert from radians to degrees
degrees(tfloat): tfloat
SELECT degrees(tfloat '[0.785398163397448@2000-01-01, 2.35619449019234@2000-01-02]'); -- "[45@2000-01-01, 135@2000-01-02]"
Get the derivative over time of the temporal float in units per second
derivative(tfloat): tfloat
The temporal float must have linear interpolation
SELECT derivative(tfloat '{[0@2000-01-01, 10@2000-01-02, 5@2000-01-03], [1@2000-01-04, 0@2000-01-05]}') * 3600 * 24; -- Interp=Stepwise;{[-10@2000-01-01, 5@2000-01-02, 5@2000-01-03], [1@2000-01-04, 1@2000-01-05]} SELECT derivative(tfloat 'Interp=Stepwise;[0@2000-01-01, 10@2000-01-02, 5@2000-01-03]'); -- ERROR: The temporal value must have linear interpolation