# Sort Dataset by Timestamp

**URL:** <https://forum.inductiveautomation.com/t/sort-dataset-by-timestamp/39885>\
**Category:** Ignition Early Access\
**Tags:** vision, perspective, scripting, database, ignition80\
**Created:** [October 21, 2020, 6:13pm UTC](https://forum.inductiveautomation.com/t/sort-dataset-by-timestamp/39885 "2020-10-21T18:13:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nickboratyn](https://avatars.discourse-cdn.com/v4/letter/n/9d8465/32.png) [@nickboratyn](https://forum.inductiveautomation.com/u/nickboratyn)\
**Post date:** [October 21, 2020, 6:13pm UTC](https://forum.inductiveautomation.com/t/sort-dataset-by-timestamp/39885/1 "2020-10-21T18:13:54Z")

</div>

I have a dataset that has 2 columns, the first is the timestamp and the second is a value column for a particular tag.  
I want to sort that dataset to return a dataset of values for one hour.  
Can anyone help?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 21, 2020, 6:16pm UTC](https://forum.inductiveautomation.com/t/sort-dataset-by-timestamp/39885/2 "2020-10-21T18:16:21Z")

</div>

Have you seen the documentation for [system.dataset.sort](https://docs.inductiveautomation.com/display/DOC80/system.dataset.sort)?

---

<div class="post-metadata">

**Author:** ![nickboratyn](https://avatars.discourse-cdn.com/v4/letter/n/9d8465/32.png) [@nickboratyn](https://forum.inductiveautomation.com/u/nickboratyn)\
**Post date:** [October 21, 2020, 6:18pm UTC](https://forum.inductiveautomation.com/t/sort-dataset-by-timestamp/39885/3 "2020-10-21T18:18:33Z")

</div>

I did look at that; however, I was not sure if it was possible to capture just one hour out of the current dataset. the current dataset hold a days worth of data for a particular tag.

-edit-  
I can sort out and get just a single column and sort it is ascending or descending, but as far as getting what I want I am still stumped

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 21, 2020, 6:29pm UTC](https://forum.inductiveautomation.com/t/sort-dataset-by-timestamp/39885/4 "2020-10-21T18:29:55Z")

</div>

Sort the data first, then determine what rows to keep and apply the opposite operation via [https://docs.inductiveautomation.com/display/DOC80/system.dataset.deleteRows](https://docs.inductiveautomation.com/display/DOC80/system.dataset.deleteRows).  
If you’ve got a consistent sample rate, you can even just do the math; eg keep the first 60 records and remove the rest.

---

<div class="post-metadata">

**Author:** ![mjohnson](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@mjohnson](https://forum.inductiveautomation.com/u/mjohnson)\
**Post date:** [January 28, 2021, 8:16pm UTC](https://forum.inductiveautomation.com/t/sort-dataset-by-timestamp/39885/5 "2021-01-28T20:16:35Z")

</div>

If you use the system.dataset.sort on a week or two weeks worth of data and try to sort on the date (timestamp) in descending order, will it actual sort based off Monday through Friday? It does not seem to work that way for me, unless I am doing something wrong here.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [January 28, 2021, 10:01pm UTC](https://forum.inductiveautomation.com/t/sort-dataset-by-timestamp/39885/6 "2021-01-28T22:01:31Z")

</div>

Well, descending would give Friday down to Monday, is that what you’re seeing?
