cancel
Showing results for 
Search instead for 
Did you mean: 

How to obtain difference btw 2 timestamp?

aleung
Contributor III

Any idea how to obtain seconds, minutes, or hours between 2 timestamp?

1 ACCEPTED SOLUTION

In the above example just dont use the quotes, instead send as JSON object!! Otherwise you will get the warning from the platform at runtime.

Date.now().toLocaleDateString({“timeZone”:“PST”, “format”:“yyyy-MM-dd”})

View solution in original post

13 REPLIES 13

vipulk10
New Contributor III

convert both timestamps to epoch using getTime() function and simply subtract them ie a-b . Result is in milliseconds.
Further there lookup at https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1439344/Date+Functions+and+Properties .
date extension which might help you

I already tried it. It works with Date.now().getTime() but the following example didn’t
e.g. $extracts_refreshed_at.getTime() <== where $extracts_refreshed_at is _snaptype_localdatetime

Here is the error I am getting:
Failure: Unknown method: getTime, Reason: Object has an unknown type (org.joda.time.LocalDateTime), Resolution: Please check expression syntax

dmiller
Former Employee

Let me check with Dev to see if it is limited to date-time only.


Diane Miller

del
Contributor III

@aleung, it’s not pretty, but I think you can solve with DateTime.parse($extracts_refreshed_at.toString()).getTime()