Pulling the Max Date From An Array Of Differently Formatted Date Fields | Community
Skip to main content
Eric_D_Miller
Level 5
May 2, 2025
Solved

Pulling the Max Date From An Array Of Differently Formatted Date Fields

  • May 2, 2025
  • 3 replies
  • 939 views

Hello,

 

I am trying to pull the latest/max date from an array of differently formatted dates:
Here is the data I am pulling into an array. The different highlights show that some dates have a timestamp while others do not.

Here is a good example of a bunlde in my array:

The goal is to get the latest date from each bundle, and apply that date to new field. 

 

Best answer by Lawson02

Maybe someone else has a more elegant solution but this is what I came up with. Dates with no time automatically default to 12:00am

 

 

 

3 replies

Lawson02
Lawson02Accepted solution
Level 6
May 5, 2025

Maybe someone else has a more elegant solution but this is what I came up with. Dates with no time automatically default to 12:00am

 

 

 

RandyRoberts
Community Advisor
Community Advisor
May 7, 2025

data from the array

 

reverse sort descending by hour entryDate

 

get 1st entry from the sorted array

 

Eric_D_Miller
Level 5
May 7, 2025

Thank you Randy,

 

Each of my bundles have 11 different date fields that may or may not be populated. My goal is to end up with only one date value from each bundle which should be the latest date.

 

Your example is helpful but in it there is only one date, entryDate. How can I apply what you instructed but considering my bundles have eleven date fields instead of just one?

Sven-iX
Community Advisor
Community Advisor
May 9, 2025

I think @lawson02's answer is elegant and simple. By converting the date value to a timestamp, there is no need to sort/reverse since we're now in math-land and can use max/min etc. Added bonus, if you go from a true date field (ie not a text field) you avoid timezone headaches by converting to a timestamp.

 

Only change I would make is to set vars separately, so if needed to can cleanup the value before parsing - but still same approach as Lawson provided.