# Number of days between two dates

**URL:** <https://community.blaze.today/t/number-of-days-between-two-dates/32056>\
**Category:** Questions and Help\
**Created:** [September 7, 2023, 6:45am UTC](https://community.blaze.today/t/number-of-days-between-two-dates/32056 "2023-09-07T06:45:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Keith\_Fairbairn](https://community.blaze.today/user_avatar/community.blaze.today/keith_fairbairn/32/8963_2.png) [@Keith\_Fairbairn](https://community.blaze.today/u/Keith_Fairbairn)\
**Post date:** [September 7, 2023, 6:45am UTC](https://community.blaze.today/t/number-of-days-between-two-dates/32056/1 "2023-09-07T06:45:32Z")

</div>

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](https://blaze.today/gallery/calculators/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

---

<div class="post-metadata">

**Author:** ![AshwinMittal](https://community.blaze.today/user_avatar/community.blaze.today/ashwinmittal/32/18048_2.png) [@AshwinMittal](https://community.blaze.today/u/AshwinMittal)\
**Post date:** [September 7, 2023, 6:59am UTC](https://community.blaze.today/t/number-of-days-between-two-dates/32056/2 "2023-09-07T06:59:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Keith\_Fairbairn](https://community.blaze.today/user_avatar/community.blaze.today/keith_fairbairn/32/8963_2.png) [@Keith\_Fairbairn](https://community.blaze.today/u/Keith_Fairbairn)\
**Post date:** [September 7, 2023, 7:12am UTC](https://community.blaze.today/t/number-of-days-between-two-dates/32056/3 "2023-09-07T07:12:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AshwinMittal](https://community.blaze.today/user_avatar/community.blaze.today/ashwinmittal/32/18048_2.png) [@AshwinMittal](https://community.blaze.today/u/AshwinMittal)\
**Post date:** [September 7, 2023, 7:21am UTC](https://community.blaze.today/t/number-of-days-between-two-dates/32056/4 "2023-09-07T07:21:18Z")

</div>

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}

---

<div class="post-metadata">

**Author:** ![Keith\_Fairbairn](https://community.blaze.today/user_avatar/community.blaze.today/keith_fairbairn/32/8963_2.png) [@Keith\_Fairbairn](https://community.blaze.today/u/Keith_Fairbairn)\
**Post date:** [September 7, 2023, 7:39am UTC](https://community.blaze.today/t/number-of-days-between-two-dates/32056/5 "2023-09-07T07:39:31Z")

</div>

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.
