DateTime feature request

DateTime feature request

kthorngrenkthorngren Posts: 18,541Questions: 25Answers: 4,396

Using DateTime with date range filters can be problematic if the table dates aren't ISO format. DateTime returns the date with the local time. This doesn't work well when using moment to parse the dates. Use this example from this thread to see the problem. Choose June 16 for the min date and the following will appear in the output for the row with June 16:

min date date: Thu Jun 16 2022 05:31:26 GMT-0400 (Eastern Daylight Time)
moment date: q {_isAMomentObject: true, _i: '16/06/2022', _f: 'DD/MM/YYYY h:m A', _isUTC: false, _pf: {…}, …}

The comparison of (min <= date && max === null) will not pass so the row is hidden.

There are other threads with similar problems:

There are additional steps needed when using moment. What are the recommended ways to combine comparing moment objects with DateTime objects?

This one suggests there is some inconsistency with returning the time.

The request is to either provide a way to just create a date only DateTime object or provide documentation and examples of how this works to eliminate confusion with just the generic example.



  • allanallan Posts: 58,873Questions: 1Answers: 9,471 Site admin

    Hi Kevin,

    Excellent point - this has come up a few times recently. The Javascript Date object doesn't have the option of being a date only, so what I've done is to add a little bit to DateTime that will initialise the time to be 0 when the is no time component in the format.

    The upshot of that is that in the generic example if you select 11th August 2013 for the min value it will now correctly match a single row.


  • kthorngrenkthorngren Posts: 18,541Questions: 25Answers: 4,396

    Perfect, thanks.


Sign In or Register to comment.