Forums

Datepicker Ordering Issue

MaryLynn 23 Nov, 2012
Hello, this a problem I did not realize until recently as it's the end of the year.

I use the format mm.dd.yyyy for the Datepicker in one of my forms, but when I order by dates, it's putting 2013 dates above the 2012 ones. This makes our schedules really confusing to read.
Is there any way to fix this?
GreyHead 24 Nov, 2012
Hi MaryLynn,

The date format mm.dd.yyyy is practically useless for sorting :-( You need to use yyyy.mm.dd to get any sensible result.

Ideally you'd save the dates in a useful format and just re-format them to display. Practically this may not be possible in which case you probably have to and a hand-coded sort to the list with code that uses re-formatted dates.

Where exactly so you see the problem? How is the list produced and sorted now?

Bob
MaryLynn 24 Nov, 2012
The list is generated by the DB Multi Record Loader, which loads user schedules from a database generated by a form that has the Datepicker.

The WHERE statement is
<?php
 global $_CB_framework;
$bcuser = $_CB_framework->displayedUser();
echo "`cf_user_id` = $bcuser";
?> ORDER BY Date_Begins


This portion is to get the user's schedule on their Community Builder profile.
GreyHead 24 Nov, 2012
Hi MaryLynn,

You can try ORDER BY UNIX_TIMESTAMP(`Date_Begins`) and see if that will convert the date for you.

Bob
emmexx 24 Nov, 2012
I save dates in a field in the format dd/mm/yyyy.

To order the records in a multirecord db loader I add the following in the WHERE field of the action:

...
ORDER BY CONCAT(
  RIGHT(Date_begins,4),
  '-',
  SUBSTRING(Date_begins,4,2),
  '-',
  LEFT(Date_begins,2)
)


Hope this helps!

maxx
This topic is locked and no more replies can be posted.