cancel
Showing results for 
Search instead for 
Did you mean: 

months (jan,feb,mar..)not getting sorted in a timestamp

Former Member
0 Kudos

Hi All,

I am facing a problem in how sorting a date in the format of "dd-MMM-yy HH.mm.ss" where MMM = jan,feb,mar....dec.

The problem is the numeric part of the date is getting sorted whereas the month is not getting sorted like 13 - June 10 should come after 21 - Jan 10 when sorted in descending order

The requirement is strictly in this format that's why cannot keep it as dd-MM-yy(MM as numeric) which gets sorted easily.

(I am using NWDS CE7.1 with JDK 1.5.0_06)

Request you to help me in getting a solution on this.

Thank You.

Regards,

Reinuka.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Reinuka,

I am facing a problem in how sorting a date in the format of "dd-MMM-yy HH.mm.ss"--You can sort this kind of date format too. Convert this date format into Date type and then sort.

Please refer the below thread, having solution for same question:-

Hope this may help you.

Deepak!!!

Former Member
0 Kudos

Hi Deepak,

Thanks for your quick reply.

I went through the thread mentioned by you but I would want to know whether we have to implement this in tablesorter.java or in the onactionsort() event.I would like to add that the column values have been converted into a string froma timestamp.So, I would be converting this string into a date and will then compare it.Also, all this involves a dynamic coding for the table and its columns.

Request you to help me on this.

Regards,

Reinuka.

Former Member
0 Kudos

Hi Reinuka,

I think in the table sorter you are passing String value as parameter for sorting therefor you are getting strign based sorted output. If Date is a column then you can use node's sort method and able to sort the table based on the date column.

Or

Select Date as a data type for the date column in place of String and try. When you are about to set the value in table column you can manipulate the format and display as you want and sort.

Deepak!!!

Former Member
0 Kudos

Hi Deepak,

I tried with both the options you gave.

If I change the column from string to a date using parse I am loosing the format ("dd-MMM-yy HH.mm.ss") and when I maintain the format its getting sorted properly.

By changing this string column into a date datatype is sorting the column easily but the format doesn't remain the same.

When where will you set the format for just displaying it..sorting always sorts on the value stored in the attribute mapped to the column..how can i change this stored date datatype into string at the time of display..

Really appreciate your help on the above.

Thank You.

Regards,

Reinuka.

Former Member
0 Kudos

Self resolved by adding a custom date datatype.