# Returning earliest date in a dataset with an expression?

**URL:** <https://forum.inductiveautomation.com/t/returning-earliest-date-in-a-dataset-with-an-expression/26636>\
**Category:** Ignition\
**Created:** [July 17, 2019, 4:52pm UTC](https://forum.inductiveautomation.com/t/returning-earliest-date-in-a-dataset-with-an-expression/26636 "2019-07-17T16:52:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [July 17, 2019, 4:52pm UTC](https://forum.inductiveautomation.com/t/returning-earliest-date-in-a-dataset-with-an-expression/26636/1 "2019-07-17T16:52:05Z")

</div>

Hey y’all,

As always I appreciate any help I can get. I have dataset tags that I need to parse and return the earliest and latest date for. I have searched the forums and haven’t come up with much. Script or expression doesn’t matter.

Times are formated as: 2019-07-17 11:13:19.779

---

<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:** [July 17, 2019, 4:59pm UTC](https://forum.inductiveautomation.com/t/returning-earliest-date-in-a-dataset-with-an-expression/26636/2 "2019-07-17T16:59:23Z")

</div>

Use the [`sortDataset`](https://docs.inductiveautomation.com/display/DOC80/sortDataset) function, then return the first row; something like:  
`sortDataset({reference.to.dataset}, "timestamp")[0, "timestamp"]`

---

<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:** [July 17, 2019, 5:41pm UTC](https://forum.inductiveautomation.com/t/returning-earliest-date-in-a-dataset-with-an-expression/26636/3 "2019-07-17T17:41:56Z")

</div>

An expression example, for completeness:

```auto
minDate({Root Container.Power Table.data},'Date Column')

```

---

<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:** [July 17, 2019, 5:47pm UTC](https://forum.inductiveautomation.com/t/returning-earliest-date-in-a-dataset-with-an-expression/26636/4 "2019-07-17T17:47:38Z")

</div>

:doh: forgot about `minDate` entirely.
