Is there a way in Workflow 11 to convert a date or date time to timestamp or epoch? I'm trying to integrate a process with a 3rd party api and it only accepts timestamp or epoch values.
Question
Question
Answer
Good afternoon Cassandra
Have you tried using the token calculator with this formula?
DATEDIF(Date(1970,1,1) , %(Date), "D") * 86400
Given today's date of 2024-03-13, the answer 1710288000 appears to be correct when checked against this online tool: https://www.epochconverter.com/
(add 3 more zeros on the end for the millisecond version)
Let me know if that works.
Thank you
Replies
Hello Cassandra
Can you provide an example of what format exactly the 3rd party API is expecting? There are a number of functions in Workflow for DateTime format conversions. Input/Output examples would be great.
Thank you
Yes, the API would expect epoch "1701061200000" if Date was 11/27/2003. Workflow Token Calculator can convert an epoch time to date but not the reverse.
There is this Answers post from 2019 but was hoping there had been an update to Workflow since this that included the functionality.
Good morning Cassandra
You are correct that Workflow has a built-in function for Epoch to Date, that works with timestamps to the second, but there is not function for doing this in reverse.
Based on your example above, you are looking to convert only the Date portion of a DateTime item to unix ticks, correct? It also appears that the API is expecting the millisecond version of the timestamp, correct?
Thank you
I can do Date or DateTime - either will work. The API will return a millisecond result but does not require one to be sent. It will just assume 0 if none is provided.
Good afternoon Cassandra
Have you tried using the token calculator with this formula?
DATEDIF(Date(1970,1,1) , %(Date), "D") * 86400
Given today's date of 2024-03-13, the answer 1710288000 appears to be correct when checked against this online tool: https://www.epochconverter.com/
(add 3 more zeros on the end for the millisecond version)
Let me know if that works.
Thank you
That works great! Thank you so much :D