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
4 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?
Please sign in to leave a comment.