ibjdt
Programmer
- Nov 25, 2002
- 63
the following snippet is from a script that sorts a table.
the script works well, but as you can see from the comments in this snippet, dates aren't neccessarily sorted in correct order.
eg 6-10-05 comes before 6-2-05
is there a fix for this??
the script works well, but as you can see from the comments in this snippet, dates aren't neccessarily sorted in correct order.
eg 6-10-05 comes before 6-2-05
is there a fix for this??
Code:
// VALUE TO SORT IS A DATE, REMOVE ALL OF THE PUNCTUATION AND
// AND RETURN THE STRING NUMBER
//BUG - STRING AND NOT NUMERICAL SORT .....
// ( 1 - 10 - 11 - 2 - 3 - 4 - 41 - 5 etc.)
var myDate = new String();
myDate = isDate.getFullYear() + " " ;
myDate = myDate + isDate.getMonth() + " ";
myDate = myDate + isDate.getDate(); + " ";
myDate = myDate + isDate.getHours(); + " ";
myDate = myDate + isDate.getMinutes(); + " ";
myDate = myDate + isDate.getSeconds();
//myDate = String.fromCharCode(48 + myDate.length) + myDate;
return myDate ;