[Info-ingres] Doing arithmetic with ANSI dates
Karl Schendel
schendel at kbcomputer.com
Thu Oct 28 14:17:38 UTC 2021
> On Oct 28, 2021, at 4:08 AM, Roy Hann <specially at processed.almost.meat> wrote:
>
> Karl Schendel wrote:
>>
>> You'll want an INTERVAL.
>>
>> SELECT birthdate + INTERVAL '3' MONTH FROM ...
>
> Aha. I had encountered that in my reading but it was not clear (till
> now) that it is the standard syntax. Thank you.
>
> For completeness, it seems like the permitted keywords are DAY, MONTH,
> and YEAR only...right?
It's a bit more complicated than that. I don't have the full syntax at hand, but
the options are YEAR, MONTH, DAY, HOUR, MINUTE, SECOND,
YEAR TO MONTH, and DAY TO HOUR, MINUTE, or SECOND.
Intervals can have either year and month fields, or day / hour / minute / second
fields, but not both for some bizarre reason that I don't know.
The quoted part in the middle is 'year-month' for a year to month interval,
and 'day hour[:min[:second]]' for a day to second interval. You can have
a leading minus sign (inside the quotes) to indicate a negative interval.
>
> And while I am here, Ingres accepts ANSIDATE + INTEGER. The integer is
> interpretted as a number of days. Does the standard endorse such an
> expression?
I don't think it does.
Karl
More information about the Info-ingres
mailing list