Date parsed as string

Date parsed as string

Ironwil616Ironwil616 Posts: 50Questions: 0Answers: 0
edited October 2011 in General
I've read other posts on this, and thought the problem was to be fixed, but I'm still getting incorrect date sorting. Some date values can be empty. When I do the sort by date, it's almost correct, but obviously is doing a left to right string sort. Years end up out of order if the month/day combo is lesser/greater than another around it, and "12" for a month comes before "2".

Help!

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    not enough info

    are you setting an sType for that column? which are you using?

    which date sorting routine(s) are you using or intend to use? plugins?
  • GregPGregP Posts: 500Questions: 10Answers: 0
    edited October 2011
    Agreed, not enough info.

    Our application sorts by date in a number of locations, but it keeps track of dates in "milliseconds since 1970" timestamp, so sorting is always accurate right to the millisecond. I have this value converted to a string on the client side instead of having the string sent from the server side.

    But that's assuming server-side, and assuming you have access to the date as a plain old integer.
  • jp_noronhajp_noronha Posts: 59Questions: 0Answers: 0
    you should try universal date as sorting plugin for dates.
    i believe it will solve your date problem

    http://www.datatables.net/forums/discussion/6587/unidate-universal-date-sorting-plugin/p1
  • Ironwil616Ironwil616 Posts: 50Questions: 0Answers: 0
    edited October 2011
    Sorry for the long wait before response. I've been under a crazy load. No, I haven't been setting an sType for that column. I can try that, though since the search defaults to a string if any values are empty, this makes me wonder if the sType assignment will cause an issue when the empty values are parsed. I've been using the built-in sorting routines provided by dataTables, no plugins just yet, though I'll give the plugin suggested by jp_noronha a try as soon as I can.

    I'm not doing things server-side in this instance. One of the requirements for this table is to provide column-specific filters. Though server-side processing would certainly help performance (must run in IE, which renders dataTables horribly slow compared to Chrome), due to the large return sets I'm handling, doing this really makes the column filters a wasted effort, except for the drop-down lists. Those I populate from a limited known set of values from the server on the initial data grab, so they have all the possible values, even if none of the column's current values do. This also speeds up initialization, since the JavaScript has no need to grab data from the columns and create the select elements. When several columns used these filters created in JavaScript, IE brought that "stop script" dialog up. That's off-topic, but it's why I'm grabbing full data sets and then applying dataTables to the rendered table.

    At any rate, I'll delve more into the date sorting later this week. Thanks for the replies.
This discussion has been closed.