cancel
Showing results for 
Search instead for 
Did you mean: 

How to find date difference between two dates?

Surendar
Contributor

I need to find the date different between two dates. There is no option available for datediff in SnapLogic.
I tried with minus function in expression but won’t work.

date1 - date2 also won’t work

datatype:date-time

date 1: 2017-10-16T09:42:01.582
date 2: 2017-08-08T00:00:00.000

3 REPLIES 3

dmiller
Former Employee

See also this thread How to obtain difference btw 2 timestamp?


Diane Miller

Yes I have found the solution using the getTime() but its limited to date-time datatype. If suppose the datatype may vary facing undefined getTime issue for local-date-time and etc.

date difference:

Math.floor(($date1.getTime() - $date2.getTime() ) / (1000 * 60 * 60 * 24))

I checked with Dev and historically we’ve seen people format the local time into a string and then do Date.parse().


Diane Miller