Subject | Re: [firebird-support] Re: Add Year function |
---|---|
Author | Aage Johansen |
Post date | 2006-04-14T18:58:18Z |
Adam wrote:
consensus on how this was done (or should be done).
In my old documentation for SysTools there are 2 routines for adding
months to a date: one that makes 29.01.2005 + 1 month into
01.03.2005, and another that keeps the date within the next month
(29.01.2005 + 1 month ends up as 28.02.2005).
Anyhow, one sometimes has to do things like this. And either way,
someone is likely to be less than totally satisfied...
--
Aage J.
>I don't disagree with you. I just wondered whether there were
>> Btw, which date is 1 month after 29.02.2004 ? And 1 month before
> 30.03.2006?
>
> To me it is a nonsense. It is like comparing sales for two months. I
> have seen people confused why there is huge sales variations from one
> month to the next, when some months have more weekends than others.
> You can't add a year to a number, nor can you add a month to it.
> Although it is sometimes possible to do, programming is largely
> mathematics. It requires fixed rules, and any exceptions dealt with.
> If you are going to define this date next month as
>
> if m = 12 then
> begin
> m = 1;
> y = y + 1;
> end
> else
> begin
> m = m + 1;
> end
>
> Then that will hit an issue as soon as you get to the end of january
> and hit a day that does not actually exist in february. As a side
> note, I am aware of at least one popular dbms that happily accepts
> nonesense dates like 29 Feb 2006.
>
> Your specification must explain the result of adding a month to 29 Jan
> 2006.
>
consensus on how this was done (or should be done).
In my old documentation for SysTools there are 2 routines for adding
months to a date: one that makes 29.01.2005 + 1 month into
01.03.2005, and another that keeps the date within the next month
(29.01.2005 + 1 month ends up as 28.02.2005).
Anyhow, one sometimes has to do things like this. And either way,
someone is likely to be less than totally satisfied...
--
Aage J.