This article explains how to use handlebars helpers to calculate the number of days between dates.
21*24*60*60 = 1814400 = seconds in 21 days.
timestamp:
{{timeStamp}}
date+offset:
{{dateAdd myDate 1814400000}} //dateAdd uses milliseconds
timeStamp in seconds from epoch:
{{dateFormat 'X' timeStamp}}
myDate in seconds from epoch:
{{dateFormat 'X' myDate}}
myDate in seconds + 21 days:
{{add 1814400 (dateFormat 'X' myDate)}} {{#compare (add 1814400 (dateFormat 'X' timeStamp)) ">" (dateFormat 'X' myDate)}}
21 days from now is greater than myDate
{{else}}
21 days from now is less than myDate
{{/compare}}
Comments
Tom Santiago,
I only found adding number of days to the original dates, Can you help in figure out how to compare two dates and the difference in days?
Vamshi Reddy,
Can you try this solution to help you resolve that issue?
https://docs.celigo.com/hc/en-us/community/posts/360078072592-Comparing-NOW-date-function-
I’m receiving the error: “Missing Helper: dateAdd”
Sorry, ellan reddy. Could you share the full statement for us to try to troubleshoot?
Stephen Brandt - Basically, I need to add 2 years to the 'Last Modified Date'. I did follow the above provided syntax, but running into issues. Can you please help me out here?
ellan reddy, is the handlebars statement failing to calculate as intended, or are you getting a design-time or runtime error? Perhaps you could post a screen capture here or paste in the error message.
Please sign in to leave a comment.