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.
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
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
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
Data from my array
data from the array
reverse sort descending, group by hourID
reverse sort descending by hour entryDate
reverse sorted data
grab only the first array item for each hourID (bundle)
get 1st entry from the sorted array
lates entry from each bundle
Views
Replies
Total Likes
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?
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies