# How to auto calculate values every month or using no. of days?

**URL:** <https://community.glideapps.com/t/how-to-auto-calculate-values-every-month-or-using-no-of-days/41013>\
**Category:** Ask for Help\
**Created:** [April 21, 2022, 9:42am UTC](https://community.glideapps.com/t/how-to-auto-calculate-values-every-month-or-using-no-of-days/41013 "2022-04-21T09:42:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Th.Nitin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/th.nitin/32/72291_2.png) [@Th.Nitin](https://community.glideapps.com/u/Th.Nitin)\
**Post date:** [April 21, 2022, 9:42am UTC](https://community.glideapps.com/t/how-to-auto-calculate-values-every-month-or-using-no-of-days/41013/1 "2022-04-21T09:42:49Z")

</div>

I want to calculate salaries of employees every month, I have **annual pay package** and the **month of joining** as the data source. So, I want to automate this process.

**Edge Cases** : 1. Suppose an employee joins on the 16th day of the month. And as per the norms I have to give him salary for the 14 days only. Now I can give him salary by the end of the joining month or on the end of next consecutive month. The consecutive month salary will be addition of 14 days salary and the following month salary.

Anyone have any idea of implementing this auto calculation?

---

<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:** [April 21, 2022, 11:58pm UTC](https://community.glideapps.com/t/how-to-auto-calculate-values-every-month-or-using-no-of-days/41013/2 "2022-04-21T23:58:45Z")

</div>

So the end result you want is to view how much salary you have to pay each of your employees in the current month?

---

<div class="post-metadata">

**Author:** ![Th.Nitin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/th.nitin/32/72291_2.png) [@Th.Nitin](https://community.glideapps.com/u/Th.Nitin)\
**Post date:** [April 22, 2022, 3:24am UTC](https://community.glideapps.com/t/how-to-auto-calculate-values-every-month-or-using-no-of-days/41013/3 "2022-04-22T03:24:36Z")

</div>

@ThinhDinh , yes

---

<div class="post-metadata">

**Author:** ![Th.Nitin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/th.nitin/32/72291_2.png) [@Th.Nitin](https://community.glideapps.com/u/Th.Nitin)\
**Post date:** [April 23, 2022, 5:34am UTC](https://community.glideapps.com/t/how-to-auto-calculate-values-every-month-or-using-no-of-days/41013/4 "2022-04-23T05:34:32Z")

</div>

Is there any way to implement this 👆 👆

---

<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:** [April 23, 2022, 9:35am UTC](https://community.glideapps.com/t/how-to-auto-calculate-values-every-month-or-using-no-of-days/41013/5 "2022-04-23T09:35:33Z")

</div>

I think here’s a logic to get you going. I assume you will pay “partial salary” on the same month.

1st part: The date templates.

- Create a column to calculate the “joined month” of the employee.
- Create a column to calculate the “joined year” of the employee.
- Create a template to join the “joined month” and “joined year”. Let’s say “3 - 2022”.
- Create a column to calculate the “current month”.
- Create a column to calculate the “current year”.
- Create a template to join the “current month” and “current year”. Let’s say “4 - 2022”.

2nd part: The salary calculation.

- Create a math column to calculate the “Days in joined month” number. Let’s say if it’s April 2022 then 30.

- Create a math column to calculate the “Date joined” number. Let’s say if 15 April then 15.

- Create a math column to calculate the “Days paid in joined month” number. Take the “Days in joined month” number and subtract it from the “Date joined” number, plus 1. Let’s say if you join on 30 April you’ll be paid 30 - 30 + 1 = 1 day. This doesn’t take into account the complexity of working and non-working days.

- Create a math column to calculate the “Days in current month” number.

- Create a math column to calculate the “Salary in joined month” number, take the daily salary and times it by the “Days paid in joined month” number.

- Calculate the “Salary in current month” number, take the daily salary and times it by the “Days in current month” number.

- Finally, create an If Then Else column. If the two templates in the first part matches (meaning the employee joined this month), then return the “Salary in joined month” number, else return the “Salary in current month” number.

---

<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:** [April 23, 2022, 9:37am UTC](https://community.glideapps.com/t/how-to-auto-calculate-values-every-month-or-using-no-of-days/41013/6 "2022-04-23T09:37:57Z")

</div>

Info on how to calculate a month’s number of days.

> [@Fun with Dates](https://community.glideapps.com/t/fun-with-dates/21684/134):
>
> Jean-Claude does not stop here hehe. Darren’s idea made me think about a formula to derive the current month’s number of days. And here we go! Tested some timestamps. N+31-(FLOOR(DAY(N)/16))\*15+1-DAY(N+31-(FLOOR(DAY(N)/16))\*15) - (N+1-DAY(N)) Edit: Realized a bug with 28 is that when you start with dates like 1, 2 in a 31-day month then it does not convert. Back to the drawing board. Edit 2: Derived a way to add 16 days when it’s “day 16 or more”, and 31 days when it’s “less than …
