Page 1 of 1

How do I get the date 30 days from today? - Solved

Posted: Fri Dec 09, 2016 8:15 pm
by DR White
How do I get the date 30 days from today?

I have looked in the dictionary, but I could not find any info on getting a future date based on today's date.

Any help would be appreciated,

David

Re: How do I get the date 30 days from today?

Posted: Fri Dec 09, 2016 8:24 pm
by dunbarx
One of the most fun and powerful keywords in LC is the dateItems. It can do calculations within itself.

Code: Select all

on mouseUp
   convert the date to dateItems
   add 30 to item 3 of it
   convert it to date
   answer it
end mouseUp
So much fun.

Craig

EDIT:

If you just convert the date, the result goes into "it". You could have done this in other ways.
You can go backwards too: "subtract 2000 from item 3 of it"
You can use the dateItems format to do all sorts of things. Who says you can only change the day item? Play around, and read the dictionary entry for this gem.

Re: How do I get the date 30 days from today?

Posted: Fri Dec 09, 2016 8:40 pm
by DR White
Craig,

Wow!

That works Great!!

Thanks,

David

Re: How do I get the date 30 days from today? - Solved

Posted: Fri Dec 09, 2016 8:58 pm
by dunbarx
Hi.

Read my edits. Your thanks can be converted to a half hour of fiddling with this keyword.

Craig

Re: How do I get the date 30 days from today? - Solved

Posted: Fri Dec 09, 2016 9:06 pm
by dunbarx
New post. I must not be too cavalier about some things.

So you can add 500 to item 1 of the dateItems, but this will not give you a valid result. But what if you convert the long date?

So much fun.

Craig