# \[Bug-2737\] Perspective table - sorting date column

**URL:** <https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 10, 2020, 2:58pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213 "2020-01-10T14:58:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![justin.brzozoski](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justin.brzozoski/32/13452_2.png) [@justin.brzozoski](https://forum.inductiveautomation.com/u/justin.brzozoski)\
**Post date:** [January 10, 2020, 2:58pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/1 "2020-01-10T14:58:25Z")

</div>

Running Ignition 8.0.6, we have a table with a column full of timestamps. We set the columns.render property to "date" and sortable to true. When we sort the date column, it seems to be sorting based on the string-formatted time rather than the actual timestamp.

For example, if I had the dateFormat set to "MM/DD/YYYY" and sorted by date, I might see these items in this order:

> 12/16/2019  
> 12/06/2019  
> 01/05/2020

Note that the "12/06/2019" entry is out of order, I suspect because '0' comes after '2' in string ASCII sorting. Even worse, I suspect that if I had another entry from January of 2019, it would show up adjacent to the Januar 2020 entry instead of at the beginning.

I expected the items to be sorted in chronological order.

---

<div class="post-metadata">

**Author:** ![lwood](https://avatars.discourse-cdn.com/v4/letter/l/977dab/32.png) [@lwood](https://forum.inductiveautomation.com/u/lwood)\
**Post date:** [April 2, 2020, 7:55pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/2 "2020-04-02T19:55:08Z")

</div>

This happens in 8.0.7 too.

It will go 3/29 -\> 3/3 -\> 3/30 -\> 3/31

---

<div class="post-metadata">

**Author:** ![lwood](https://avatars.discourse-cdn.com/v4/letter/l/977dab/32.png) [@lwood](https://forum.inductiveautomation.com/u/lwood)\
**Post date:** [April 27, 2020, 2:56pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/3 "2020-04-27T14:56:30Z")

</div>

I sent in an email to Inductive Support and if you render the column as ‘auto’ instead of date the sorting works correctly. I don’t think it’s being dealt with as a bug just as designed.

The formatting still works.

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [February 12, 2021, 2:48pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/4 "2021-02-12T14:48:23Z")

</div>

Did you ever find a solution to this? It still seems to not work with either option in 8.1.1

---

<div class="post-metadata">

**Author:** ![lwood](https://avatars.discourse-cdn.com/v4/letter/l/977dab/32.png) [@lwood](https://forum.inductiveautomation.com/u/lwood)\
**Post date:** [February 12, 2021, 2:51pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/5 "2021-02-12T14:51:55Z")

</div>

Nope I just turned off sorting on columns where it didn’t work.

---

<div class="post-metadata">

**Author:** ![chasondeshotel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chasondeshotel/32/20032_2.png) [@chasondeshotel](https://forum.inductiveautomation.com/u/chasondeshotel)\
**Post date:** [February 12, 2021, 3:33pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/6 "2021-02-12T15:33:48Z")

</div>

This is why YYYY/MM/DD is the superior format. Sort with regular old sort. Users will learn to accept it

---

<div class="post-metadata">

**Author:** ![lwood](https://avatars.discourse-cdn.com/v4/letter/l/977dab/32.png) [@lwood](https://forum.inductiveautomation.com/u/lwood)\
**Post date:** [February 12, 2021, 3:47pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/7 "2021-02-12T15:47:20Z")

</div>

If only dealing with users was that easy 🤣

---

<div class="post-metadata">

**Author:** ![chasondeshotel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chasondeshotel/32/20032_2.png) [@chasondeshotel](https://forum.inductiveautomation.com/u/chasondeshotel)\
**Post date:** [February 12, 2021, 3:59pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/8 "2021-02-12T15:59:52Z")

</div>

“Do you want sort or do you want stupid format? You can’t have both. You know why the rest of the world uses YYYY/MM/DD? This is why. What’s the deal with imperial measurement anyway–who the hell thought base 12 was a good idea? And don’t get me started on our healthcare-” “Okay, sure, I can do it wrong if that’s what you want but like I said they won’t sort.” “Oh you don’t care that much just get it done? 10-4”

---

<div class="post-metadata">

**Author:** ![justin.brzozoski](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justin.brzozoski/32/13452_2.png) [@justin.brzozoski](https://forum.inductiveautomation.com/u/justin.brzozoski)\
**Post date:** [February 12, 2021, 7:10pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/9 "2021-02-12T19:10:13Z")

</div>

In the long run, we used something similar to this as a transform on our dataset binding, so the table is pre-sorted by dates:

```auto
def sort_dataset_by_date(dset, date_column, ascending=True):
	orig_columns = system.dataset.getColumnHeaders(dset)
	tstamps = [system.date.toMillis(x) for x in dset.getColumnAsList(date_column)]
	dset = system.dataset.addColumn(dset, 0, tstamps, 'tmp_tstamp', long)
	dset = system.dataset.sort(dset, 0, ascending)
	return system.dataset.filterColumns(dset, orig_columns)

```

If you’re using this for a table component, you can leave the `tmp_stamp` column in place and just not display it.

---

<div class="post-metadata">

**Author:** ![Cory.grube](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cory.grube/32/20476_2.png) [@Cory.grube](https://forum.inductiveautomation.com/u/Cory.grube)\
**Post date:** [June 3, 2021, 9:57pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/10 "2021-06-03T21:57:35Z")

</div>

I tested this on 8.1.5, and sorting works for me if `props.columns[N].render` is set to `auto`  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/a/ca7728943d60c67216f80170e5e24e0b3f9a974d.png)

Unfortunately it’s still busted if you set `render` to `date`  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/4/b41db550817775415037a82def05dd8ca9a006a9.png)

---

<div class="post-metadata">

**Author:** ![jcorey](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jcorey/32/26937_2.png) [@jcorey](https://forum.inductiveautomation.com/u/jcorey)\
**Post date:** [June 3, 2021, 10:41pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/11 "2021-06-03T22:41:00Z")

</div>

Ignition version 8.1.6 contains several bug fixes which had impacted the sorting of Table columns, including the ability to sort a column by date. In 8.1.6 and newer versions, you should find that timestamps and string dates sort appropriately. Please reply in this thread with any feedback or concerns while using 8.1.6 or newer.

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [June 4, 2021, 8:17pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/12 "2021-06-04T20:17:40Z")

</div>

Definitely still broken for date sorting in 8.1.6.

Original table data is date…

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/e/6eaa943f1d33240f15fd3edf66c4b26871b12d6c.png)

Sorting is still all over the place with render: auto OR render: date

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/8/4898b600e8021e05c4fadc073ef7641ffff4a631.png)

Maybe part of the problem is at least in my case there are null values in some of the rows. However, I would still expect it to sort the non null values correctly.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/7/77c3f2ccdcd7214da6df2d7826608cb8ab1950f4.png)

---

<div class="post-metadata">

**Author:** ![jcorey](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jcorey/32/26937_2.png) [@jcorey](https://forum.inductiveautomation.com/u/jcorey)\
**Post date:** [June 4, 2021, 9:22pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/13 "2021-06-04T21:22:13Z")

</div>

Is there anyway you could provide a mock up reproducing the issue so I can give it a look. I tried reproducing it with a dataset tag as well as trying to mimic your data structure without success. Thanks.

---

<div class="post-metadata">

**Author:** ![jcorey](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jcorey/32/26937_2.png) [@jcorey](https://forum.inductiveautomation.com/u/jcorey)\
**Post date:** [June 7, 2021, 4:20pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/14 "2021-06-07T16:20:14Z")

</div>

I was finally able to reproduce this issue and have since opened an internal ticket.

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [June 7, 2021, 4:34pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/15 "2021-06-07T16:34:39Z")

</div>

Ok, cool. I just reproduced it in a view as well. (See attached). I made a dummy DB (MSSQL) query to generate some random dates and am able to replicate the issue consistently.

[scratch\_2021-06-07\_1232.zip](https://forum.inductiveautomation.com/uploads/short-url/yj4CXOWup36ugUM3pDGNHCPZgpC.zip) (22.6 KB)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/e/2eb3061fb6a27bfb39516b222f3396a1405b004e.png)

---

<div class="post-metadata">

**Author:** ![nicolas.griffon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nicolas.griffon/32/16603_2.png) [@nicolas.griffon](https://forum.inductiveautomation.com/u/nicolas.griffon)\
**Post date:** [August 11, 2021, 2:00pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/16 "2021-08-11T14:00:58Z")

</div>

I’m unable to understand the date sorting in 8.1.7  
I’ve tried

- Remove order by in my named query

- Change render on my table’s column to auto or date  
and it’s same false result

The date format is “DD/MM/YYYY HH:mm” because of French users

 ![bug-2737](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/e/4e3944ef154d651651c1946f2fded9a1d852ab29.png)

strangely, on some views with the same column configuration sorting on dates values seems to work.  
I have an example with rows from the audit\_logs SQL table that sorts correctly into the perspective table.

---

<div class="post-metadata">

**Author:** ![jcorey](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jcorey/32/26937_2.png) [@jcorey](https://forum.inductiveautomation.com/u/jcorey)\
**Post date:** [August 11, 2021, 2:42pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/17 "2021-08-11T14:42:10Z")

</div>

This is currently in development, we will be sure to check this scenario during testing.  
Thanks!

---

<div class="post-metadata">

**Author:** ![nicolas.griffon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nicolas.griffon/32/16603_2.png) [@nicolas.griffon](https://forum.inductiveautomation.com/u/nicolas.griffon)\
**Post date:** [September 23, 2021, 9:41am UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/18 "2021-09-23T09:41:35Z")

</div>

I’ve just installed the 8.1.10 version and it seems to be corrected.  
I can’t reproduce this sorting issue in my views with my data.  
Good job!

---

<div class="post-metadata">

**Author:** ![nicolas.griffon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nicolas.griffon/32/16603_2.png) [@nicolas.griffon](https://forum.inductiveautomation.com/u/nicolas.griffon)\
**Post date:** [September 27, 2021, 12:27pm UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/19 "2021-09-27T12:27:47Z")

</div>

Since I’ve installed the 8.1.10 version, I notice that _sometimes_ the cells of columns with a width=0 appears on my Table.  
When I inspect the Source code, I notice that the style is correct in `class="tc ia_table __cell ia_table__ head __header__ cell thc sortable"` : `style="order: 3; width: 0px; flex: 0 1 auto; max-width: 0px;"` but not on table body : `class="tc ia_table__cell"` : `style="order: 3;"`  
It’s happening on the firt loading of the view.

---

<div class="post-metadata">

**Author:** ![michal.koblasa](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@michal.koblasa](https://forum.inductiveautomation.com/u/michal.koblasa)\
**Post date:** [April 6, 2022, 6:58am UTC](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213/20 "2022-04-06T06:58:12Z")

</div>

Hello,  
the common format for our country is: dd.mm.yyyy unfortunately sort does not work in version 8.1.9 (it is sorted as string not the chronological date).

Any progress in this topic @jcorey?

Thank you for the information

[Next page](https://forum.inductiveautomation.com/t/bug-2737-perspective-table-sorting-date-column/31213.md?page=2)
