Chapter 7. Temporal Types: Alphanumeric Operations

Table of Contents

Boolean Operations
Mathematical Operations
Text Operations

Boolean Operations

  • Temporal and

    {boolean,tbool} & {boolean,tbool} → tbool

    SELECT tbool '[true@2001-01-03, true@2001-01-05)' &
      tbool '[false@2001-01-03, false@2001-01-05)';
    -- [f@2001-01-03, f@2001-01-05)
    SELECT tbool '[true@2001-01-03, true@2001-01-05)' &
      tbool '{[false@2001-01-03, false@2001-01-04),
      [true@2001-01-04, true@2001-01-05)}';
    -- {[f@2001-01-03, t@2001-01-04, t@2001-01-05)}
    
  • Temporal or

    {boolean,tbool} | {boolean,tbool} → tbool

    SELECT tbool '[true@2001-01-03, true@2001-01-05)' |
      tbool '[false@2001-01-03, false@2001-01-05)';
    -- [t@2001-01-03, t@2001-01-05)
    
  • Temporal not

    ~tbool → tbool

    SELECT ~tbool '[true@2001-01-03, true@2001-01-05)';
    -- [f@2001-01-03, f@2001-01-05)
    
  • Return the time when the temporal Boolean takes the value true

    whenTrue(tbool) → tstzspanset

    SELECT whenTrue(tfloat '[1@2001-01-01, 4@2001-01-04, 1@2001-01-07]' #> 2);
    -- {(2001-01-02, 2001-01-06)}
    SELECT whenTrue(tdwithin(tgeompoint '[Point(1 1)@2001-01-01, Point(4 4)@2001-01-04,
      Point(1 1)@2001-01-07]', geometry 'Point(1 1)', sqrt(2)));
    -- {[2001-01-01, 2001-01-02], [2001-01-06, 2001-01-07]}