# Assessing the earliest date in an array of dates

Hi all,
There are some similar answers but I cant seem to make it work for me.

When a timeline is changed for a task, a webhook is sent. I then want extract the timelines for all tasks within that group within my monday.com project board, find the earliest and latest dates, then update the value of a timeline column for an id in another board.

I can extract the dates using a GraphQL query, see the values as an array, but I can’t seem to work out how to assess a select the earliest / latest to the name update the other item.

Would love some help!

EDIT: I am using a timeline column as the source, and so would need to split and ‘tag’ the from and to dates, so that the scenario knew to assess which was the earliest of only the from dates etc.

Hi @JE , you can try the sort and reverse functions, so you can find the earliest and the latest by getting the first output in the array.

1 Like

Hey Libin, I’m self / google / ChatGPT taught, so my understanding is super basic. Could you explain a little more of what you mean. So I have my execute QL module, where would the sort & reverse functions go, and what would they look like? Thanks!

Hi @JE

Sure thing!

I’m assuming you already have an array for dates.

To sort the dates, I used {{sort(5.Start)}} to get the earliest date, and used {{reverse(5.End)}} to get the latest

So we can always get the first output for the earliest and the latest date.

Hope this helps.

1 Like

Thats awesome, thank you! I think the problem in my situation is that my source is a timeline column, and so I am struggling to assess the from’s and the to’s in a way that makes sense. I can put two additional formula columns on my board and pull out the start and end dates that way, but I would rather do it from the timeline if I can. Any ideas?

Hi @JE , so how exactly does your data look? What kind of scenario have you build so far?
If you send over some screenshots it helps us a lot to identify how we can help you.

1 Like

Thanks Bjorn - here is the flow.

I start with basic modules to get all data (appreciate I do this inefficiently).

Then use a QL Query to return all items within the pulse group and the timeline data for each:

The QL Query returns the following data:

The remainder of the flow then tries to take the data, assess it and find the earliest from date and the latest to date for the timeline data. There are 6 items in the group, so the data is being retrieved - its how to assess it that is the issue.

@JE I don’t see every important bit yet, but it looks like the issue lays in the place where you define the earliest and latest date. I am not sure what these “Set Variable” modules do (P.S. you can try to use the “Set Multiple Variables” module instead, more efficient), but make sure the:

• Output of these modules seem correct
• The output is the correct data type. It looks like its outputting an array while the last module probably expects a string/datetime
• If its a string, and it expects a date object try to use the `parseDate()` function

Hope this helps! Let me know

1 Like