Hi,
I've used the formula for calculating the number of days between 2 dates but the formula is returning the number of weeks instead of the number of days. Does anyone know how to fix this?
Here's the link: Text Blaze | Date Calculator
I actually need number of hours days and hour between the 2 dates but I'll start with getting number of days working.
Thanks,
Keith
Hi @Keith_Fairbairn,
Welcome to the forum 
Thanks for pointing out. We will update the docs soon. You can use this snippet to get the number of days and hours between two dates.
Between {formdate: YYYY-MM-DD; name=x} and {formdate: YYYY-MM-DD; name=y} there are {=floor(diff/(3600*24))} day/s and {=floor(diff/(3600))} hour/s
{note}{diff=abs({time: X; at={=x}}-{time: X; at={=y}})}{endnote: trim=yes}
Regards,
Ashwin
1 Like
Thanks @Ashwin_Mittal1...that was quick!
Do you know if it will still work if I change the date format to MMM D, YYYY?
Can I place these two formula dates anywhere in the snippet? I have custom text to use.
Keith
Yes, it will, but you need to specify the pattern
attribute while calculating the diff as well. I have done it in this snippet. In the preview it will show DD/MM/YYYY
, but on insert, it will be MMM D, YYYY
.
Regarding your second question, yes you can place them anywhere in your snippet.
Between {formdate: MMM D, YYYY; name=x} and {formdate: MMM D, YYYY; name=y} there are {=floor(diff/(3600*24))} day/s and {=floor(diff/(3600))} hour/s
{note}{diff=abs({time: X; at={=x}; pattern=MMM D, YYYY}-{time: X; at={=y}; pattern=MMM D, YYYY})}{endnote: trim=yes}
Great. I got it to work with our preferred date format.
The only challenge now is that the results are returning days and total hours, like 3 days and 72 hours. Same difference express in either days or hours. I only need days.
I realize I can only use either days or hours and not both since the hours variable would need a time of day function at both ends. I don't think I need that detail right now.
The formula is used for when I client cancels a booking.
1 Like