Re: BUG #1993: Adding/subtracting negative time - Mailing list pgsql-bugs

From Kevin Grittner
Subject Re: BUG #1993: Adding/subtracting negative time
Date
Msg-id 435F4A740200002500000246@gwmta.wicourts.gov
Whole thread Raw
List pgsql-bugs
This is probably why the ANSI SQL standard specifies that
the way to get an INTERVAL from two timestamps is to subtract
them within parentheses follow that with interval_qualifier.  Under
the standard you are required to SAY whether you want the
interval in days or hours, etc.

*interval_value_expression
    :   interval_term
    |   interval_value_expression_1 PLUS_SIGN interval_term_1
    |   interval_value_expression_1 MINUS_SIGN interval_term_1
    |   LEFT_PAREN datetime_value_expression MINUS_SIGN datetime_term
RIGHT_PAREN interval_qualifier
    ;

*interval_qualifier
    :   start_field TK_to end_field
    |   single_datetime_field
    ;

*single_datetime_field
    :   non_second_datetime_field [ LEFT_PAREN
interval_leading_field_precision RIGHT_PAREN ]
    |   TK_second [ LEFT_PAREN interval_leading_field_precision [ COMMA
interval_fractional_seconds_precision ] RIGHT_PAREN ]
    ;

*non_second_datetime_field
    :   TK_year
    |   TK_month
    |   TK_day
    |   TK_hour
    |   TK_minute
    ;

*interval_leading_field_precision
    :   UNSIGNED_INTEGER
    ;

*interval_fractional_seconds_precision
    :   UNSIGNED_INTEGER
    ;

>>> Bruce Momjian <pgman@candle.pha.pa.us>  >>>

When you do a subtraction, it isn't clear if you are
interested in "days" or "hours"

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #1993: Adding/subtracting negative time intervals
Next
From: Stephen Frost
Date:
Subject: Index name different from constraint name