# Counting days between appointments

**URL:** <https://community.glideapps.com/t/counting-days-between-appointments/75548>\
**Category:** Ask for Help\
**Created:** [August 9, 2024, 11:38am UTC](https://community.glideapps.com/t/counting-days-between-appointments/75548 "2024-08-09T11:38:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![TechnicalMilk](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/technicalmilk/32/61177_2.png) [@TechnicalMilk](https://community.glideapps.com/u/TechnicalMilk)\
**Post date:** [August 9, 2024, 11:38am UTC](https://community.glideapps.com/t/counting-days-between-appointments/75548/1 "2024-08-09T11:38:20Z")

</div>

Hey Everyone!

I have a problem which I cannot really solve atm.  
I’m making an appointment calendar for my business. I have different guests and provisions, but the days between two appointments is important (I calculate the price based on that).  
So basically I need 2 columns in my table. The first should tell me the client’s previous (NOT LAST) appointment’s date, and the other should count the days between each other. I added a counter (manually) for each client’s appointments (like its her/his 1st, 2nd, 3rd time) and as long as I’m able to track it it would not be the problem. But its not updating automatically so i need a solution, to automatically tell the postition of the appointment among all client’s appointment based on the DATE of it.

Hope you can help. Thanks.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [August 9, 2024, 11:50am UTC](https://community.glideapps.com/t/counting-days-between-appointments/75548/2 "2024-08-09T11:50:45Z")

</div>

> [@TechnicalMilk](#):
>
> The first should tell me the client’s previous (NOT LAST) appointment’s date, and the other should count the days between each other.

Can you clarify this please?  
Do you mean:

- The number of days between the previous appointment and the next appointment?
- The number of days between the previous appointment and the current date?
- Something else?

---

<div class="post-metadata">

**Author:** ![TechnicalMilk](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/technicalmilk/32/61177_2.png) [@TechnicalMilk](https://community.glideapps.com/u/TechnicalMilk)\
**Post date:** [August 9, 2024, 12:02pm UTC](https://community.glideapps.com/t/counting-days-between-appointments/75548/3 "2024-08-09T12:02:50Z")

</div>

The number of days between two appointements. Current date is not relevant 🙂  
Other things I can handle easily. The main problem is, that when I open a form, and make a new appointment it should fill out some of the values automatically.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [August 9, 2024, 12:15pm UTC](https://community.glideapps.com/t/counting-days-between-appointments/75548/4 "2024-08-09T12:15:07Z")

</div>

Can you tell us which fields should be filled automatically, related to your original question?

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [August 9, 2024, 12:36pm UTC](https://community.glideapps.com/t/counting-days-between-appointments/75548/5 "2024-08-09T12:36:22Z")

</div>

Okay, so I will assume that you have a table that lists all of your clients. In that table, create the following columns:

- A Query column that targets your Appointments table, and configure as follows:  
– Filter where Client is This row-\>Client  
– Order by Appointment Date Descending
- A Single Value column that takes the first Appointment Date from the Query column (this will be the date of each clients next appointment)
- Single Value column that takes the “1 from start” Appointment Date from the Query column (this will be the date of each clients previous appointment)
- Now you can use a Math column to calculate the number of days between the two dates using the following formula:

```auto
Round(Next - Previous)

```

---

<div class="post-metadata">

**Author:** ![TechnicalMilk](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/technicalmilk/32/61177_2.png) [@TechnicalMilk](https://community.glideapps.com/u/TechnicalMilk)\
**Post date:** [August 10, 2024, 9:48am UTC](https://community.glideapps.com/t/counting-days-between-appointments/75548/6 "2024-08-10T09:48:51Z")

</div>

Hey There! Thanks for the advice, it solved the problem Partly.  
I had the same solution already (not as elegand as yours).  
The only problem with it, that it’s only handle the last and 1 before.  
I would need a solution which tells the difference between every appointment and the one before it.  
The main reason for this, that one guest has 2-3 pendind appointment in the future all the time, and this only hadles the last and last-1.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [August 10, 2024, 9:52am UTC](https://community.glideapps.com/t/counting-days-between-appointments/75548/7 "2024-08-10T09:52:02Z")

</div>

Okay, I understand. Have a watch of the below video. I think you could adapt the technique shown to work for your use case.

https://www.loom.com/embed/042be3be13004355b0dedec1be67b400

[https://www.loom.com/share/042be3be13004355b0dedec1be67b400](https://www.loom.com/share/042be3be13004355b0dedec1be67b400)

---

<div class="post-metadata">

**Author:** ![TechnicalMilk](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/technicalmilk/32/61177_2.png) [@TechnicalMilk](https://community.glideapps.com/u/TechnicalMilk)\
**Post date:** [August 10, 2024, 9:57am UTC](https://community.glideapps.com/t/counting-days-between-appointments/75548/8 "2024-08-10T09:57:18Z")

</div>

So basically the solution lies here. But needed a little twist.

> [@Darren\_Murphy](#):
>
> Okay, so I will assume that you have a table that lists all of your clients. In that table, create the following columns:
> 
> - A Query column that targets your Appointments table, and configure as follows:  
> – Filter where Client is This row-\>Client  
> – Order by Appointment Date Descending
> - A Single Value column that takes the first Appointment Date from the Query column (this will be the date of each clients next appointment)
> - Single Value column that takes the “1 from start” Appointment Date from the Query column (this will be the date of each clients previous appointment)
> - Now you can use a Math column to calculate the number of days between the two dates using the following formula:
> 
> ```auto
> Round(Next - Previous)
> 
> ```

Here is the twist:

For every appointment I added a query column:  
-Where Client ID = Row Client ID  
AND

- The Start date is before the Start date of row
- Ascending order

Single value column:  
-Gets the first date from the Query

Math column:  
Round (This - Previous)

Voilá 🥳  
Million thanks for the help!

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [August 17, 2024, 9:57am UTC](https://community.glideapps.com/t/counting-days-between-appointments/75548/9 "2024-08-17T09:57:21Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
