Welcome! Log In Create A New Profile

Advanced

Date + 30

Posted by Paul Ziegler 
Paul Ziegler
Date + 30
February 27, 2009 12:17AM
How do I add 15 days to a date?
It appears to me that date are strings? so the dDate = dDate + 15 does not work.

Thanks,

Paul Ziegler
Paul Ziegler
Re: Date + 30
February 27, 2009 12:35AM
I found it. Took me awhile, but I think I have the best way.

dDate..Day+=15

Carlo Hermus
Re: Date + 30
February 27, 2009 12:37AM
Paul,

Like this

dDate is date

Add 15 days

dDate = dDate..day + 15

Add 2 months

dDate = dDate..month + 2

Add 2 years

dDate = dDate..year + 2
Paul Ziegler
Re: Date + 30
February 27, 2009 12:42AM
Carlo,

Thanks. It was very helpful. My brain in trapped in the my old design tool way of thinking and sometimes it takes awhile to find the answer in the help.

Paul
Milton
Re: Date + 30
February 27, 2009 04:38AM
Paul,

Also remember that to do the date arithmetic it has to done as variables such as shown in Carlo's examples.

Milton
Paul Ziegler
Re: Date + 30
February 27, 2009 05:38PM
Carlos,

This does not seem to work.

dDate is Date //dDate takes on the value 20090227
dDate = dDate..Day + 15 //dDate now shows the value 18000211

This works.

dDate is Date
dDate..Day+=15 // dDate now shows the value 20090314

I am using WD12. What am I doing wrong?

Paul



Jimbo
Re: Date + 30
February 27, 2009 06:48PM
Quote
Paul Ziegler
Carlos,

This does not seem to work.

dDate is Date //dDate takes on the value 20090227
dDate = dDate..Day + 15 //dDate now shows the value 18000211

This works.

dDate is Date
dDate..Day+=15 // dDate now shows the value 20090314

I am using WD12. What am I doing wrong?

Paul

Hi Paul,

dDate = dDate..Day +15 // dead wrong !

think dDate..Day equals 10
then add 15 equals 25
and then you're setting the full date to 25 ! This will not work ..
Regards,
Guenter
Paul Ziegler
Re: Date + 30
February 27, 2009 08:04PM
Guenter,

Thanks for the reply. Then I assume the correct way to add 15 days to a date is:

dDate..Day+=15

This gives me the desired result. Is there another, or better way of doing this?

Paul
David Martin
Re: Date + 30
February 27, 2009 08:43PM
Like the help file says:

// Example on an item
Work.StartDate = "20011225"

// Add 5 days to the date
Work.StartDate..Day += 5 // this ADDS 5 days to the date

// Modify the days
Work.StartDate..Day = 10 // this CHANGES the day to 10

The following arithmetic operators can be used by Day:

++ and --

+= and - =

StartDate is date = "20041126"
StartDate..Day++ // Add 1 day to the date
StartDate..Day+=5 // Add 5 days to the date
StartDate..Day-=5 // Subtract 5 days from the date

Paul Ziegler
Re: Date + 30
February 28, 2009 05:01PM
David,

Thanks for the reply. I am set now.


Paul
Erik Schwarz
Re: Date + 30
March 01, 2009 04:15PM
Another thing that works always:

date = integertodate(datetointeger()+30)

Erik
Paul Ziegler
Re: Date + 30
March 02, 2009 05:48PM
Erik,

Thanks for the response.

Paul
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: