Subject | SQL Date Arithmetic |
---|---|
Author | Jim Starkey |
Post date | 2001-07-19T14:34:03Z |
Does anybody know what the official semantics of date
arithmetic in SQL?
The Interbase semantics are these:
<date> + <whatever> => 'date' incremented by numeric value of
'whatever', interpreted as number of day,
giving a date
<date> - <whatever> => floating point number representing the
number of days between 'date' and
'whatever' interpreted as a date.
Oracle semantics are the above plus a second alternative for
<date> - <whatever> => 'date' decremented by numerica value
of 'whatever', interpreted as a date,
giving a date.
Among the problems with the Oracle semantics is that a date
minus a string requires interpretation of the string to determine
the actual operator and the type of the result.
Perhaps our mole of the SQL Committee can shed some light on the
official line.
Jim Starkey
arithmetic in SQL?
The Interbase semantics are these:
<date> + <whatever> => 'date' incremented by numeric value of
'whatever', interpreted as number of day,
giving a date
<date> - <whatever> => floating point number representing the
number of days between 'date' and
'whatever' interpreted as a date.
Oracle semantics are the above plus a second alternative for
<date> - <whatever> => 'date' decremented by numerica value
of 'whatever', interpreted as a date,
giving a date.
Among the problems with the Oracle semantics is that a date
minus a string requires interpretation of the string to determine
the actual operator and the type of the result.
Perhaps our mole of the SQL Committee can shed some light on the
official line.
Jim Starkey