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

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

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

Post by DR White » Fri Dec 09, 2016 8:15 pm

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
Last edited by DR White on Fri Dec 09, 2016 8:41 pm, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

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

Post by dunbarx » Fri Dec 09, 2016 8:24 pm

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.
Last edited by dunbarx on Fri Dec 09, 2016 8:57 pm, edited 1 time in total.

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

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

Post by DR White » Fri Dec 09, 2016 8:40 pm

Craig,

Wow!

That works Great!!

Thanks,

David

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

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

Post by dunbarx » Fri Dec 09, 2016 8:58 pm

Hi.

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

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

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

Post by dunbarx » Fri Dec 09, 2016 9:06 pm

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

Post Reply