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

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


Diane Miller
Community Manager

del
Contributor III

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