New topic: Problem adding days to date.
<http://forums.realsoftware.com/viewtopic.php?t=46841> Page 1 of 1 [ 5 posts ] Previous topic | Next topic Author Message paulsondervan Post subject: Problem adding days to date.Posted: Wed Feb 06, 2013 11:40 am Joined: Fri Jul 09, 2010 7:16 am Posts: 81 Location: Den Haag, Netherlands I 'm trying to add 30 days to the system date. Dim SysDate As New Date dtmVervaldatum.DateValue = Sysdate dtmVervaldatum.Day = dtmVervaldatum.Day + 30 Today is the 06-02-2013 (6th of February) and adding 30 days would give me 08-03-2013 (8th of March). When I perform the above code, the result is 28-02-2013 (28th of February). Is this a bug or am I doing something wrong? _________________ MacBook Pro (late 2008), OSX Mountain Lion 10.8.2, Real Studio 2012r2 Top ktekinay Post subject: Re: Problem adding days to date.Posted: Wed Feb 06, 2013 12:05 pm Joined: Mon Feb 05, 2007 5:21 pm Posts: 429 Location: New York, NY I can't reproduce that here. This code gives me the expected date: dim d as new Date d.Day = d.Day + 30 AddToResult d.SQLDate Try this instead: dim d as new Date d.TotalSeconds = d.TotalSeconds + ( 30. * 24. * 60. * 60. ) AddToResult d.SQLDate As a general rule, you're better off manipulating TotalSeconds than Day, Minute, etc. _________________ Kem Tekinay MacTechnologies Consulting http://www.mactechnologies.com/ Need to develop, test, and refine regular expressions? Try RegExRX. Top p0wn3d Post subject: Re: Problem adding days to date.Posted: Wed Feb 06, 2013 12:19 pm Joined: Sun Oct 28, 2012 4:54 am Posts: 163 Location: Herts, UK This works for me. Dim today as New date today.day = today.day + 30 MsgBox(Str(today.ShortDate)) _________________ Real Studio 2012 R2 SysInfo BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD Top HMARROQUINC Post subject: Re: Problem adding days to date.Posted: Wed Feb 06, 2013 2:42 pm Joined: Sun Jan 25, 2009 5:11 pm Posts: 413 Location: Guatemala, Central America Works here too _________________ Future RS guru. Ride the world! Top paulsondervan Post subject: Re: Problem adding days to date.Posted: Thu Feb 07, 2013 1:53 am Joined: Fri Jul 09, 2010 7:16 am Posts: 81 Location: Den Haag, Netherlands I found the problem. The field (dtmVervaldatum) where I added the 30 days was a DateControl field (Einhugur). After I added the 30 days to a date field and moved the result in the DateControl field, the result was as expected. Thank you all for your replies. _________________ MacBook Pro (late 2008), OSX Mountain Lion 10.8.2, Real Studio 2012r2 Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 5 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml rbforumnotifier@monkeybreadsoftware.de