[Gambas-user] BUG: Problem with DateAdd function

Werner wdahn at ...1000...
Sat Dec 4 18:22:43 CET 2010


On 05/12/10 01:08, Werner wrote:
> On 05/12/10 00:37, Benoît Minisini wrote:
>   
>>> 2010/2/13 Benoît Minisini <gambas at ...1...>:
>>>     
>>>       
>>>>> I've run into a strange problem with the DateAdd function, when trying
>>>>> to subtract from the current date by months.
>>>>>
>>>>> I initially hit the problem with the following (values are hard-coded
>>>>> for clarity):
>>>>> DateAdd(cdate("2/13/2010"),gb.month,-37)
>>>>>
>>>>> It seems that any combination of Date and Interval that results in a
>>>>> date of January 2007 causes an "Invalid Date" error.  For example, the
>>>>> following are all invalid:
>>>>> DateAdd(cdate("1/13/2010"),gb.month,-36)
>>>>> DateAdd(cdate("2/28/2010"),gb.month,-37)
>>>>> DateAdd(cdate("3/13/2010"),gb.month,-38)
>>>>>
>>>>> Changing the starting date or the number of intervals so as to have a
>>>>> date that falls outside the month of January 2007 works okay.  It also
>>>>> works okay using periods of Year or Week that fall into those dates.
>>>>>
>>>>> =======
>>>>>
>>>>> System information:
>>>>>
>>>>> Gambas Version 2.13
>>>>> Components in project: gb.db, gb.db.form, gb.form, gb.gui, gb.settings,
>>>>> gb.vb
>>>>>
>>>>> OS: Ubuntu 9.10 Karmic Koala; Kernel 2.6.31-19-generic-pae
>>>>> GNOME 2.28.1
>>>>>
>>>>> Hardware: Intel Core 2 Duo processor (E8400)
>>>>>         
>>>>>           
>>>> The bug has been fixed in revision #2697.
>>>>
>>>> Regards,
>>>>
>>>> --
>>>> Benoît Minisini
>>>>       
>>>>         
>>> This is a reply to and old post, but I'd gone off onto other projects,
>>> and am just revisiting this...
>>>
>>> I am currently running version 2.22.0 and am still getting the error
>>> described above.  If the bug had been fixed in an earlier version, it
>>> seems to have crept back in.
>>>
>>> My Ubuntu version is currently 10.04 LTS (Lucid Lynx)
>>>
>>> Thanks,
>>>
>>> -George
>>>
>>>     
>>>       
>> Can anyone reproduce that? 
>>
>> I can't. I get the correct result each time with gambas 2.22.0.
>>
>> ?DateAdd(cdate("1/13/2010"),gb.month,-36)
>> 13/01/07
>> ?DateAdd(cdate("2/28/2010"),gb.month,-37)
>> 28/01/07
>> ?DateAdd(cdate("3/13/2010"),gb.month,-38)
>> 13/01/07
>>
>>   
>>     
> Gambas 2.19/64 Suse11.3 locale Hong Kong:
>
> PRINT DateAdd(CDate("2/13/2010"), gb.month, -36)
> PRINT DateAdd(CDate("3/28/2010"), gb.month, -37)
> PRINT DateAdd(CDate("4/13/2010"), gb.month, -38)
> produces
> 13/02/07
> 28/02/07
> 13/02/07
>
> whereas
> PRINT DateAdd(CDate("1/13/2010"), gb.month, -36)
> PRINT DateAdd(CDate("2/28/2010"), gb.month, -37)
> PRINT DateAdd(CDate("3/13/2010"), gb.month, -38)
> all produce an invalid date error.
>
> Regards
> Werner
>   
Forgot to mention it works in Gambas3 version 3293.





More information about the User mailing list