[Gambas-user] BUG: Problem with DateAdd function

Benoît Minisini gambas at ...1...
Sat Dec 4 17:37:15 CET 2010


> 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

-- 
Benoît Minisini




More information about the User mailing list