sort date column according to date data not display data

sort date column according to date data not display data

kimsiakimsia Posts: 14Questions: 0Answers: 0
edited January 2012 in General
Hi Allan,

1 more question.

I have a date column that will display user friendly dates like

today 04:11
yesterday 03:45
Wednesday 11:33
Jan 03 07:18
Nov 01 2011 09:13

I believe the sorting would not work with such string format. (But correct me if I am wrong.)

So I was wondering if there is a way to allow me to keep this display while allowing the sorting in datatables.net to continue to work properly.

Right now I have a table DISPLAYING 7 columns.

I can provide a data with 8 columns with the 8th column being the date in the original date format.

Thank you.

Replies

  • kimsiakimsia Posts: 14Questions: 0Answers: 0
    sorry Allan.

    Apparently your datatables.net is so intelligent that it can sort based on the user-friendly date format as well.

    Correct me if i am wrong.

    Thank you!
  • allanallan Posts: 63,540Questions: 1Answers: 10,476 Site admin
    Yeah - that's wrong ;-). DataTables (on the client-side) will correctly sort anything that Date.parse() can do in Javascript - it cannot do "Today" for example. A sorting plug-in would be needed for that. However, from your other posts you are using server-side processing where the sorting is done by an SQL engine. As long as you are storing the data in a date type field, then the sorting will be correctly applied based on that field type, so all is well!

    Allan
  • kimsiakimsia Posts: 14Questions: 0Answers: 0
    Ah... yes, so it is my server side doing the processing. That is great!
This discussion has been closed.