Page 1 of 1

AddDate Bug

Posted: Thu Mar 31, 2005 4:45 pm
by DarkDragon
Hey,

A german guy has found a bug(Charlie in the German Forum):

Code: Select all

Debug AddDate(ParseDate("%dd.%mm.%yyyy", "31.05.2005"), #PB_Date_Month, 1)
It doesn't work with increasingvalue 1, but with another value:

Code: Select all

Debug ParseDate("%dd.%mm.%yyyy", "31.05.2005")
Debug AddDate(ParseDate("%dd.%mm.%yyyy", "31.05.2005"), #PB_Date_Month, 2)
Debug FormatDate("%dd.%mm.%yyyy", AddDate(ParseDate("%dd.%mm.%yyyy", "31.05.2005"), #PB_Date_Month, 2))

Re: AddDate Bug

Posted: Thu Mar 31, 2005 5:20 pm
by traumatic
There is no 31.06.2005 ! :)
(It also won't work with +4 etc.)

Re: AddDate Bug

Posted: Thu Mar 31, 2005 5:34 pm
by thefool
traumatic wrote:There is no 31.06.2005
:lol:

Posted: Thu Mar 31, 2005 5:59 pm
by DarkDragon
OMG, why can't it be 1.7.2005 then?

btw.: by adding 2 to the month it is my next birthday ^^

Posted: Thu Mar 31, 2005 6:32 pm
by thefool
i just tried:

Code: Select all

Debug AddDate(ParseDate("%dd.%mm.%yyyy", "27.05.2005"), #PB_Date_Month, 1)

works perfectly :)

Code: Select all

Debug ParseDate("%dd.%mm.%yyyy", "20.05.2005")
Debug AddDate(ParseDate("%dd.%mm.%yyyy", "20.05.2005"), #PB_Date_Month, 2)
Debug FormatDate("%dd.%mm.%yyyy", AddDate(ParseDate("%dd.%mm.%yyyy", "20.05.2005"), #PB_Date_Month, 2))
works too :D

Posted: Thu Mar 31, 2005 7:06 pm
by Charlie
@traumatic
sure 31.06.2005 does not give, but why it can not return 30.06.2005 or 01.07.2005 as result?

Posted: Thu Mar 31, 2005 7:52 pm
by traumatic
AddDate() returns -1 meaning it's not a legal date.

If AddDate() was just adding 30 days, it would be up to the programmer
to check if it's a valid date. The date functions as they are implemented
by now save you all the "hard work" and make perfectly sense IMHO.

I do understand you want AddDate() to 'jump' to the next legal date but
there's the next question: Next day? Previous day?

I think it's better to leave the choice up to the programmer (read: you ;)).
Having a returnvalue of -1 it's fairly easy to code whatever behaviour you'd
expect your program to have.

Well, just my 2ct. but definitely not a bug.