Searching between 2 dates?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
JackBroughton
Posts: 9
Joined: Tue Oct 21, 2014 2:18 am

Searching between 2 dates?

Post by JackBroughton »

Hi LiveCoders

I am pretty new to LiveCode and need some help.

I want to create a list of objects that were created between a certain date.

I have the 2 dates that the user inputs to search between but I cannot find a way to find all objects that were created between those dates.

I hope that makes sense and someone can help?

Thanks in advance.
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10504
Joined: Wed May 06, 2009 2:28 pm

Re: Searching between 2 dates?

Post by dunbarx »

Hi.

There are a lot of date functions. Play around with them all, especially read up on the "convert" command.

But the easiest way to do what you want is to know that there are several "timers" in LC, in the sense that counters have been set up, not since the beginning of time, but reasonably far back to be useful in everyday tasks without having to do any calculations.

So try this in a button:

Code: Select all

answer the seconds
Now write a simple handler in that same button that will take an arbitrary date and convert that value to "seconds". (remember that "convert" command?) Now think about being able to take any two dates, and convert them both to two distinct "seconds" values.

You are getting warm. Write back if you get stuck.

Craig Newman
Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Searching between 2 dates?

Post by Simon »

Hi,
Let me add one more term "dateItems".
You should use that for all your date related math. (trust me) :)

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2734
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Searching between 2 dates?

Post by jmburnod »

Hi,
This thread would be useful:

http://forums.livecode.com/viewtopic.ph ... ilit=+date
Best regards
Jean-Marc
https://alternatic.ch
JackBroughton
Posts: 9
Joined: Tue Oct 21, 2014 2:18 am

Re: Searching between 2 dates?

Post by JackBroughton »

Thank you all for your help, I got it working with convert but jmburnod your method worked brilliantly and was much more efficient then my solution.

Thank you all again
Post Reply