dbTalk Databases Forums  

Re: [BUGS] BUG #1993: Adding/subtracting negative time

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss Re: [BUGS] BUG #1993: Adding/subtracting negative time in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kevin Grittner
 
Posts: n/a

Default Re: [BUGS] BUG #1993: Adding/subtracting negative time - 10-26-2005 , 09:26 AM






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
Quote:
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
Quote:
single_datetime_field
;

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

*non_second_datetime_field
: TK_year
Quote:
TK_month
TK_day
TK_hour
TK_minute
;

*interval_leading_field_precision
: UNSIGNED_INTEGER
;

*interval_fractional_seconds_precision
: UNSIGNED_INTEGER
;

Quote:
Bruce Momjian <pgman (AT) candle (DOT) pha.pa.us
When you do a subtraction, it isn't clear if you are
interested in "days" or "hours"

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.