Getting the future date
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Getting the future date
Hi,
How can I get the future date?
Let's say today is Aug 30. What date can it be after 24 hours/86400sec?
It can be Aug 31 or Sep 1st. Is there a way to get the correct future date?
I tried "convert the second+86400 to the date," but it did not work. Please advice.
Thanks for your time!
Louis
How can I get the future date?
Let's say today is Aug 30. What date can it be after 24 hours/86400sec?
It can be Aug 31 or Sep 1st. Is there a way to get the correct future date?
I tried "convert the second+86400 to the date," but it did not work. Please advice.
Thanks for your time!
Louis
Re: Getting the future date
Hi.
Read up in the dictionary about the "dateItems". This little gadget has it all. For your question, you would "convert" a dateItem string to whatever you want to into, say, the long date.(pseudo)
Other ways, if you only want the current date after 86400 seconds, is something like:
There are a lot of ways to do this in LC.
Craig
Read up in the dictionary about the "dateItems". This little gadget has it all. For your question, you would "convert" a dateItem string to whatever you want to into, say, the long date.(pseudo)
Code: Select all
get the long date
convert it to dateitems
add someValueOrOtherToOneOfTheItemsInThedateItemsString
convert it from dateItems to long date and long timeCode: Select all
on mouseup
get the seconds
add 86400 to it
convert it to long date
answer it
end mouseupCraig
Last edited by dunbarx on Wed Sep 07, 2022 10:20 pm, edited 1 time in total.
Re: Getting the future date
If you want a silly ride concerning dates, check out;
https://forums.livecode.com/viewtopic.p ... ng#p138530
Craig
https://forums.livecode.com/viewtopic.p ... ng#p138530
Craig
Re: Getting the future date
I'd go with Craig's suggestion of using dateItems, very useful for this... worth looking it up in the dictionary and searching online for examples
dictionary wrote:A list in dateItems format can have values beyond the expected range for any given item (e.g. a day of the month of less than 1 or greater than the number of days in that month) without causing issues when converting it again later, outputting a date adjusted for such an irregularity. For example, the date 4 weeks from today can be determined by adding 28 to the third item (i.e. the day of the month) and then re-converting.
Re: Getting the future date
It helps
Thank you!
Re: Getting the future date
Stam, et. al.
An even nicer thing about dateItems is that one can do anything one feels like with it:
You get a date near the end of the decade. DateItems cares nothing about its contents being a legitimate date. It only holds the math and does the math.
Craig
An even nicer thing about dateItems is that one can do anything one feels like with it:
Code: Select all
on mouseUp
get the date
convert it to dateItems
add 2000 to item 3 of it -- add 2000 days to item 3, the day number
convert it to long date
answer it
end mouseUpCraig
