Subject | Re: Add Year function |
---|---|
Author | Adam |
Post date | 2006-04-14T04:50:30Z |
--- In firebird-support@yahoogroups.com, Aage Johansen <aagjohan@...>
wrote:
of that. (It does make you wonder what happenned to any data in the
import process that was sent through for 29 Feb 2000, since the Y2K
issue would have assumed it to be 29 Feb 1900 which did not exist.
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.
Adam
wrote:
>Yep, which means he is lucky that in this case there is no possibility
> Adam wrote:
> >> The reason I need to add 100 years is I exported data from MS
> > Access 2
> >> to Firebird.
> >> I found some of the date were not Y2K compliant, eg. 04/06/2001
> > became
> >> 04/06/1901.
> >>
> >> So I need to convert them by adding 100 years into the data.
> >> If the date is less than 1910 after export I found these need to be
> >> added by 100 years, that's why I need the update statement.
> >
> > OK, well you can just add the appropriate number of days.
> >
> > For dates >= 1 Mar 1900, simply add 36525
> > For dates <= 28 Feb 1900, simply add 36524
> >
> > For the date 29 Feb 1900, there is no corresponding day (you are
> > stuffed in this case). 1900 is a leap year but 2000 was not.
> >
>
>
> Or vice versa. 1900 is not, 2000 is.
>
of that. (It does make you wonder what happenned to any data in the
import process that was sent through for 29 Feb 2000, since the Y2K
issue would have assumed it to be 29 Feb 1900 which did not exist.
> Btw, which date is 1 month after 29.02.2004 ? And 1 month before30.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.
Adam