Sort date grid by date items

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
shoshinsha
Posts: 35
Joined: Fri Jul 18, 2014 5:17 am

Sort date grid by date items

Post by shoshinsha » Thu Jan 08, 2015 8:45 am

Hi,

I have a Data Grid that contains a "date" field (converted to dateItems) per row.
My problem is whenever I sort the datagrid by date, the dates are not sorted as ascending/descending as I wanted to.
For example:

Code: Select all

 dispatch "SortDataByKey" to grp "tgrid1" with "date", "international", "ascending", "false"
After sorting, I got:
2014,10,8,13,12,22,25
2014,12,25,9,13,5,26
2014,2,13,6,0,48,7
2014,2,13,6,52,48,2
2014,5,5,11,29,6,3
2014,5,5,3,12,36,37
...

While the correct ascending date should be:
2014,2,13,6,0,48,7
2014,2,13,6,52,48,2
2014,5,5,3,12,36,37
2014,5,5,11,29,6,3
2014,10,8,13,12,22,25
2014,12,25,9,13,5,26
...

I've tried using normal date and time records on that field, but the months could not be sorted accordingly Jan, Feb, Mar, ..., they will be sorted in alphabetical order instead.
Any advices on how to sort for date?

Thanks in advance! :)

shoshinsha
Posts: 35
Joined: Fri Jul 18, 2014 5:17 am

Re: Sort date grid by date items

Post by shoshinsha » Thu Jan 08, 2015 9:58 am

I figured that I can convert the date and time to seconds instead of converting to dateItems...
The way should work :wink:

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Sort date grid by date items

Post by Klaus » Thu Jan 08, 2015 1:35 pm

shoshinsha wrote:I figured that I can convert the date and time to seconds instead of converting to dateItems...
The way should work :wink:
Yes :D

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”