cancel
Showing results for 
Search instead for 
Did you mean: 

Find max date

skodali
New Contributor III

Hi,

How can we find the max between dates?
I’m trying to find the newly created date between the dates below.

2021-05-19T19:01:47.000+0000
2021-05-19T22:11:26.000+0000

3 REPLIES 3

cjhoward18
Employee
Employee

Hi,

In a mapper snap you can use this expression to return the date that is earlier(or equal) if your dates are strings, otherwise if the values are already Dates, you can remove the calls to Date.parse():

Date.parse($date1) > Date.parse($date2) ? $date2 : $date1

skodali
New Contributor III

@cjhoward18 Thanks, for your quick response. But those two dates will be in the same column. How can I find the recently created date from the same column?

Check out the Aggregate snap:
https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1438462/Aggregate

I used the snap configured like this screenshot below with a series of documents from a json generator that have a field called date1. Applying the Max function allowed me to find the Max date:

Screen Shot 2021-06-10 at 10.23.45 AM

** correction I misread the post, you would want to use the MAX function not MIN.