Welcome! Log In Create A New Profile

Advanced

How do I calculate a future date?

Posted by Dan M 
Dan M
How do I calculate a future date?
June 30, 2009 08:22PM
I am sure this is an easy one (if you can find the function) but I have not been able to find it in the help ...

I want to calculate ... Future date = (Today + X days)

NextCallDate = (DateSys() + 1)

I tried the above and it returns 200906301

which is appending the number one to the end of the date which is being stored as YYYYMMDD.

What is ... or where can I find the command to calculate the future date?

Any help is always appreciated

Dan
Arie
Re: How do I calculate a future date?
June 30, 2009 08:44PM
Dan, you have several options

NextCallDate = IntegerToDate(DateToInteger(DateSys()) + Xdays)

or

dTmp is date = DateSys()
dTmp..day += Xdays

Note:
dTmp..Day = dTmp..Day + XDays will generate a runtime error - direct assignment is not allowed - see the help for more info

Arie
DW
Re: How do I calculate a future date?
June 30, 2009 08:51PM
Hey Dan

Date..Day -=7

or

Date..Day +=7

Dennis
Piet van Zanten
Re: How do I calculate a future date?
June 30, 2009 09:11PM
Hi Dan,

Some more info:
Originally Windev started with dates only in string format. Later they added the date type.
Datesys() returns a string, so if you add "1" to it. you will get a concatenation of two strings. As Arie and Dennis stated, you can perform direct calculations on the date type. For the traditional string type date you have to use functions like integertodate.

Regards,
Piet
Dan M
Re: How do I calculate a future date?
July 02, 2009 01:38AM
Thank you to all ...(Arie, Dennis, & Piet)

Arie, your first explanation was exactly what I was looking for ...

Dennis, I had no idea you could do anything like that, very efficient

Piet, thanks for the explanation, your explanation about DateSys() being a string help things make sense.

Again, Thank you all for your help!!!

Dan
Goof.pcs.crosspost
Re: How do I calculate a future date?
July 02, 2009 11:21AM
Just for info, WD initialize most variable types. For a date or an hour
variable, it's initialized to the current date or time.
So "dToday is date = Today()" is equal to "dToday is date"

Rubén Sánchez Peña a écrit :
> Hi Dan. Try
>
> dToday is date = Today()
>
> You can change to other day operating over Day property of variable type
> date:
>
> dToday..Day += 10
>
>
>
> Rubén Sánchez Peña
>
Message forwarded from pcsoft.us.windev
Piet van Zanten
Re: Re: How do I calculate a future date?
July 02, 2009 03:57PM
Hi,

Yes, that can be tricky sometimes, so don't forget to initialize a date type after declaration to "" if needed.

Regards,
Piet
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: