Hi all,
i want to sort date but my date format is in 2009-11-23 8:34:47 PM type (YY-MM-DD HR:MIN:SEC AM/PM) format.
i have tried mygrid.setDateFormat("%Y-%m-%d "); but this one is not working.
can you please let me know is there is any other format exists for sorting date. or try with custom sort function.
but this one is not working.
Please check example here dhtmlx.com/docs/products/dht … ormat.html
dhtmlx.com/docs/products/dht … ormat.html
or try with custom sort function.
Tutorial is available here docs.dhtmlx.com/doku.php?id=dhtm … te_sorting
ya …
thanks man …
i tried custom function it works fine.
function time_custom(a,b,order)
{
a = a.split("-");
b = b.split("-");
if (a[0] == b[0])
{
a[1] = parseInt(a[1],10); // mm (convert 01 to 1)
b[1] = parseInt(b[1],10);
if (a[1] == b[1])
{
var dateTimeA = a[2];
var dateTimeB = b[2];
a[2] = parseInt(a[2].substring(0,a[2].indexOf(" ")),10); // dd
b[2] = parseInt(b[2].substring(0,b[2].indexOf(" ")),10);
if(a[2] == b[2]) // consider time
{
var timeA = dateTimeA.substring(dateTimeA.indexOf(" ")+1,dateTimeA.indexOf(".",dateTimeA.indexOf(" ")+1));
var timeB = dateTimeB.substring(dateTimeB.indexOf(" ")+1,dateTimeB.indexOf(".",dateTimeB.indexOf(" ")+1));
timeA = timeA.split(":");
timeB = timeB.split(":");
timeA[1] = parseInt(timeA[1],10);
timeB[1] = parseInt(timeB[1],10);
if(timeA[1] == timeB[1])
{
timeA[2] = parseInt(timeA[2],10);
timeB[2] = parseInt(timeB[2],10);
if(timeA[2] == timeB[2])
{
timeA[3] = parseInt(timeA[3],10);
timeB[3] = parseInt(timeB[3],10);
return(timeA[3]>timeB[3]?1:-1)*(order=="asc"?1:-1);
}
else
{
return(timeA[2]>timeB[2]?1:-1)*(order=="asc"?1:-1);
}
}
else
{
return(timeA[1]>timeB[1]?1:-1)*(order=="asc"?1:-1);
}
}
else
{
return(a[2]>b[2]?1:-1)*(order=="asc"?1:-1);
}
}
else
{
return(a[1]>b[1]?1:-1)*(order=="asc"?1:-1);
}
}
else
{
return(a[0]>b[0]?1:-1)*(order=="asc"?1:-1);
}
}