Page 1 of 1

Compare Date and Time

Posted: Sun Aug 14, 2011 3:25 pm
by tabbiati
Hello to All,
i am very new to LiveCode but i love it :D ; for me it have only a problem :cry: : difficult to easy find example for all function....
Now i need some code to compare Date and Time to see if current date or time
is in an interval.
Can someone help me?
Thanks in advance.

Re: Compare Date and Time

Posted: Sun Aug 14, 2011 3:47 pm
by Klaus
Hi tabbiati,

welcome to the forum! :D

Check these terms in the dictionary:
convert
dateitems
seconds

I am sure they will supply a solution to your problem!
And of course ask here if you get stuck!

And please check these stacks here:
http://www.runrev.com/developers/lesson ... nferences/

And here:
http://www.runrev.com/developers/lesson ... tutorials/
:D

Best from germany

Klaus

Re: Compare Date and Time

Posted: Sun Aug 14, 2011 4:27 pm
by tabbiati
Thanks Klaus,
Wow You are a rockets to answer!
I see Your indication and now i can do some test :lol:

Re: Compare Date and Time

Posted: Sun Aug 14, 2011 5:00 pm
by tabbiati
Ok, solved
Thanks Klaus!

Re: Compare Date and Time

Posted: Sun Aug 14, 2011 5:20 pm
by Klaus
Prego, amico mio :D

Re: Compare Date and Time

Posted: Wed Jan 04, 2012 1:32 pm
by calvax
Hi Tabbiati.
I need to compare date/time too because I am programming something like scheduler/organizer and it's necessary to check if current datetime is > than deadline of event
Which format of date time it's better to use?
I think to convert to seconds and after compare, can be good idea? Can I know how you solved?
thanks

Re: Compare Date and Time

Posted: Wed Jan 04, 2012 2:04 pm
by bangkok
calvax wrote:Hi Tabbiati.
I think to convert to seconds and after compare, can be good idea? Can I know how you solved?
thanks
Yes that's the way to go.

Code: Select all

put the  date into tNow
convert tNow to seconds

put "1/1/11" into tOldDate
convert tOldDate to seconds

if tNow > tOldDate then answer "After"

Re: Compare Date and Time

Posted: Fri Jan 06, 2012 4:04 pm
by calvax
thanks

Re: Compare Date and Time

Posted: Tue Apr 02, 2013 11:27 am
by Mag
bangkok wrote:
calvax wrote:Hi Tabbiati.
I think to convert to seconds and after compare, can be good idea? Can I know how you solved?
thanks
Yes that's the way to go.

Code: Select all

put the  date into tNow
convert tNow to seconds

put "1/1/11" into tOldDate
convert tOldDate to seconds

if tNow > tOldDate then answer "After"
Great, but how to let know to LiveCode if the first item of tOldDate is a mont or a day?

Re: Compare Date and Time

Posted: Tue Apr 02, 2013 2:21 pm
by dunbarx
Hi.

In the United States, where we assume that everyone speaks English and uses our date and time format, the month would come first, then the day, then the year. I have heard that people do not always follow this format, which we cannot understand.

Anyway, look up the "useSystemDate" in the dictionary. It will point you in the direction of taking control of that format.

Craig Newman

Re: Compare Date and Time

Posted: Tue Apr 02, 2013 4:46 pm
by Mag
Thank you so much for the replay dunbarx, what I have forget to mention is that I would like to use a date to calculate the expiration time of a beta version, so I have to be certain that LiveCode understands that that date is passed whenever the user use it. So if somebody have more info to implement a unique "universal" date, I will be happy.

PS
Thank you for the useSystemDate tip, I will go to read the documentation.

Re: Compare Date and Time

Posted: Tue Apr 02, 2013 7:38 pm
by dunbarx
Hi.

Well, if you use the seconds, which is format independent, you are done. All you need are a few custom functions to do the comparisons and date translations.

Is the internet date also platform and format independent?

Craig Newman

Re: Compare Date and Time

Posted: Wed Apr 03, 2013 2:13 am
by Mag
OK, so I learnt that the useSystemDate specifies whether the date and time functions should be formatted in accordance with the user's system preferences, or in the standard format used in the United States. The default value is "false", so I guess that if I hard-code a date, it will be valid for the whole world.