Sorting dates like 5/4/2009

Sorting dates like 5/4/2009

relish27relish27 Posts: 11Questions: 2Answers: 0
edited June 2009 in General
Hello, I am using datatables.net and loving it -- except I just noticed that if my column displays dates like 5/4/2009, it is not sorting them properly. I need to have the dates be 05/04/2009 instead to sort correctly. Is there any way around this? Thanks.

Replies

  • allanallan Posts: 63,230Questions: 1Answers: 10,417 Site admin
    Hi relish27,

    Date sorting can be a little tricky due to how Javascript's built in Date().parse() works. What it is probably best to do here is to put together your own sorting (and type detection if you want) functions.

    Have a look at the following plug-in sorting and type detection functions with is for UK dates in the dd/mm/yyyy format:

    http://datatables.net/plug-ins#sorting_uk_date
    http://datatables.net/plug-ins#type_uk_date

    These can be readily adapted for dates such as 5/4/2009.

    Hope this helps,
    Allan
  • relish27relish27 Posts: 11Questions: 2Answers: 0
    Thanks, Allan, I appreciate it. I'll look into this option.
This discussion has been closed.