# How to calculate time left until date+time?

**URL:** <https://community.blaze.today/t/how-to-calculate-time-left-until-date-time/25683>\
**Category:** Questions and Help\
**Created:** [January 18, 2023, 9:44pm UTC](https://community.blaze.today/t/how-to-calculate-time-left-until-date-time/25683 "2023-01-18T21:44:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bester](https://community.blaze.today/user_avatar/community.blaze.today/bester/32/6782_2.png) [@bester](https://community.blaze.today/u/bester)\
**Post date:** [January 18, 2023, 9:44pm UTC](https://community.blaze.today/t/how-to-calculate-time-left-until-date-time/25683/1 "2023-01-18T21:44:52Z")

</div>

How do I enter a formula that will automatically calculate the time left until specified time and date?

For example:  
Hello customer,

Our store will re-open on Monday, February 1st at 9:00am.

Countdown timer: {INSERT FORMULA HERE (for 16 hours and 13 days)} left to go!

---

<div class="post-metadata">

**Author:** ![Andrew\_Hall](https://community.blaze.today/user_avatar/community.blaze.today/andrew_hall/32/6231_2.png) [@Andrew\_Hall](https://community.blaze.today/u/Andrew_Hall)\
**Post date:** [January 18, 2023, 10:25pm UTC](https://community.blaze.today/t/how-to-calculate-time-left-until-date-time/25683/2 "2023-01-18T22:25:27Z")

</div>

Hey Bester,

Good question. This is pretty easy with just days or hours, but gets a little more tricky when it's both days and hours. Here's one that I created that will always assume a 9am reopening time. I wonder if anyone else has a more elegant approach than this:

Our store will reopen on {formdate: YYYY-MM-DD; default={time: YYYY-MM-DD; shift=+2D}; name=reopen} at 9:00am. That's only {if: diffcalc\>=24}{=remainingdays}{if: remainingdays\>1} days{else} day{endif} and {=remaininghours} hours away!{else}{=diffcalc} hours away!{endif: trim=right}  
{note: trim=yes}  
{diffcalc=datetimediff({time: YYYY-MM-DD HH:mm:ss}, {time: YYYY-MM-DD HH:mm:ss; at={=reopen} 09:00:00; pattern=YYYY-MM-DD HH:mm:ss},"h")}{remainingdays=round({=diffcalc}/24)-1}{remaininghours=remainder({=diffcalc},24)}{endnote: trim=yes}

---

<div class="post-metadata">

**Author:** ![bester](https://community.blaze.today/user_avatar/community.blaze.today/bester/32/6782_2.png) [@bester](https://community.blaze.today/u/bester)\
**Post date:** [January 19, 2023, 12:24am UTC](https://community.blaze.today/t/how-to-calculate-time-left-until-date-time/25683/3 "2023-01-19T00:24:35Z")

</div>

Oh wow, thank you so much!! This was very helpful 😍

---

<div class="post-metadata">

**Author:** ![bester](https://community.blaze.today/user_avatar/community.blaze.today/bester/32/6782_2.png) [@bester](https://community.blaze.today/u/bester)\
**Post date:** [January 19, 2023, 6:03pm UTC](https://community.blaze.today/t/how-to-calculate-time-left-until-date-time/25683/4 "2023-01-19T18:03:14Z")

</div>

Where can I find these hidden commands called "datetimediff" and "remainder"? Do I need a special subscription for them?

---

<div class="post-metadata">

**Author:** ![Andrew\_Hall](https://community.blaze.today/user_avatar/community.blaze.today/andrew_hall/32/6231_2.png) [@Andrew\_Hall](https://community.blaze.today/u/Andrew_Hall)\
**Post date:** [January 19, 2023, 6:33pm UTC](https://community.blaze.today/t/how-to-calculate-time-left-until-date-time/25683/5 "2023-01-19T18:33:31Z")

</div>

Those are all documented in our Formula Reference here: [Text Blaze | Formula Reference](https://blaze.today/formulas/reference/)

---

<div class="post-metadata">

**Author:** ![bester](https://community.blaze.today/user_avatar/community.blaze.today/bester/32/6782_2.png) [@bester](https://community.blaze.today/u/bester)\
**Post date:** [January 27, 2023, 5:48pm UTC](https://community.blaze.today/t/how-to-calculate-time-left-until-date-time/25683/6 "2023-01-27T17:48:48Z")

</div>

Sorry if this is a noob question but is there a way to change the formatting to MMMM Do, YYYY?

---

<div class="post-metadata">

**Author:** ![Andrew\_Hall](https://community.blaze.today/user_avatar/community.blaze.today/andrew_hall/32/6231_2.png) [@Andrew\_Hall](https://community.blaze.today/u/Andrew_Hall)\
**Post date:** [January 27, 2023, 5:59pm UTC](https://community.blaze.today/t/how-to-calculate-time-left-until-date-time/25683/7 "2023-01-27T17:59:50Z")

</div>

Not a noob question, time formatting and time calculation can be surprisingly tough.

To update that, I needed to change the format both in the date selector AND in the formula that evaluated the difference between the two times. Here's an updated version:

Our store will reopen on {formdate: MMMM Do, YYYY; default={time: YYYY-MM-DD; shift=+2D}; name=reopen} at 9:00am. That's only {if: diffcalc\>=24}{=remainingdays}{if: remainingdays\>1} days{else} day{endif} and {=remaininghours} hours away!{else}{=diffcalc} hours away!{endif: trim=right}  
{note: trim=yes}  
{diffcalc=datetimediff({time: YYYY-MM-DD HH:mm:ss}, {time: YYYY-MM-DD HH:mm:ss; at={=reopen} 09:00:00; pattern=MMMM Do, YYYY HH:mm:ss},"h")}{remainingdays=round({=diffcalc}/24)-1}{remaininghours=remainder({=diffcalc},24)}{endnote: trim=yes}

The preview in the community will still show it in the other format but when it's actually inserted upon snippet use, it'll use the format you requested.

---

<div class="post-metadata">

**Author:** ![bester](https://community.blaze.today/user_avatar/community.blaze.today/bester/32/6782_2.png) [@bester](https://community.blaze.today/u/bester)\
**Post date:** [January 27, 2023, 6:11pm UTC](https://community.blaze.today/t/how-to-calculate-time-left-until-date-time/25683/8 "2023-01-27T18:11:39Z")

</div>

Awesome!! This is perfect, exactly what I was looking for. Thank you so much!
