Subject | Re: ***SPAM*** Re: [Firebird-general] Historic reference |
---|---|
Author | Paul Vinkenoog |
Post date | 2014-08-07T16:36:30Z |
Lester wrote:
What's the sum of 12 October 1948 and 6 July 2007? Or noon plus 4:30 in the morning? Both expressions are meaningless.
You can subtract two dates/timestamps, and that gives you an interval.
And you can add an interval to a date/timestamp (or subtract it), and then you get another date/timestamp.
In Firebird, intervals are
- when subtracting timestamps: numeric(18,9), representing days and fractions of days
- when subtracting dates: integer, representing whole days
- when subtracting time values: numeric(9,4), representing seconds and fractions of seconds
This arithmetic works fine in Firebird SQL, as long as you make sure that you don't confuse date/time values with intervals.
This is allowed:
date/time + interval
date/time - interval
date/time - date/time
This isn't:
date/time + date/time
(with one exception: date + time is allowed, and makes sense)
Paul Vinkenoog
> If I add date.5 and date.25 I get 6pm in the resultBut you shouldn't add two dates (or timestamps), and in Firebird you can't.
What's the sum of 12 October 1948 and 6 July 2007? Or noon plus 4:30 in the morning? Both expressions are meaningless.
You can subtract two dates/timestamps, and that gives you an interval.
And you can add an interval to a date/timestamp (or subtract it), and then you get another date/timestamp.
In Firebird, intervals are
- when subtracting timestamps: numeric(18,9), representing days and fractions of days
- when subtracting dates: integer, representing whole days
- when subtracting time values: numeric(9,4), representing seconds and fractions of seconds
This arithmetic works fine in Firebird SQL, as long as you make sure that you don't confuse date/time values with intervals.
This is allowed:
date/time + interval
date/time - interval
date/time - date/time
This isn't:
date/time + date/time
(with one exception: date + time is allowed, and makes sense)
Paul Vinkenoog