# Calculation of days excluding weekends

**URL:** <https://community.glideapps.com/t/calculation-of-days-excluding-weekends/70578>\
**Category:** Ask for Help\
**Created:** [February 7, 2024, 12:58pm UTC](https://community.glideapps.com/t/calculation-of-days-excluding-weekends/70578 "2024-02-07T12:58:04Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![FlorianA](https://avatars.discourse-cdn.com/v4/letter/f/ebca7d/32.png) [@FlorianA](https://community.glideapps.com/u/FlorianA)\
**Post date:** [February 7, 2024, 12:58pm UTC](https://community.glideapps.com/t/calculation-of-days-excluding-weekends/70578/1 "2024-02-07T12:58:04Z")

</div>

Hello,

Is it possible to calculate the number of days between two days without counting weekends?

I know you can calculate with “date difference” but I can’t find a way to subtract the weekend.

Example:  
The number of days (or minutes) between 05/02/2024 at 05:00 and 22/02/2024 at 05:00.

Thank you

---

<div class="post-metadata">

**Author:** ![Simon\_Hill](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/simon_hill/32/94730_2.png) [@Simon\_Hill](https://community.glideapps.com/u/Simon_Hill)\
**Post date:** [February 7, 2024, 1:03pm UTC](https://community.glideapps.com/t/calculation-of-days-excluding-weekends/70578/2 "2024-02-07T13:03:47Z")

</div>

From AI:

Sure you can use the Excel formula:

=NETWORKDAYS(A1, A2, A4:A10)

Assuming you have the start date in cell A1 and the end date in cell A2, and a list of holidays in cells A4 to A10.

This formula calculates the number of business days between the dates in A1 and A2, excluding weekends and the holidays listed from A4 to A10.

---

<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:** [February 7, 2024, 1:09pm UTC](https://community.glideapps.com/t/calculation-of-days-excluding-weekends/70578/3 "2024-02-07T13:09:17Z")

</div>

@tuzin has a Math column that does this that will make your head explode. See below:

> [@date Guide on Dates & Times](https://community.glideapps.com/t/guide-mastering-dates-times/70381/2):
>
> Thank you for combining all this valuable info into one post! This is also relevant here This math formula adds N business days to a specified date assuming Saturday and Sunday are weekends. This formula will always return a business day and it doesn’t account for public holidays. date+floor(n/5)\*7+mod(n,5)-hour(date)/24-minute(date)/1440-second(date)/86400 + 2\*(max(weekday(date+floor(n/5)\*7+mod(n,5)-hour(date)/24-minute(date)/1440-second(date)/86400)-6,0)) + (max(weekday(date+floor(n/5)\*7+mo…

---

<div class="post-metadata">

**Author:** ![FlorianA](https://avatars.discourse-cdn.com/v4/letter/f/ebca7d/32.png) [@FlorianA](https://community.glideapps.com/u/FlorianA)\
**Post date:** [February 8, 2024, 5:12am UTC](https://community.glideapps.com/t/calculation-of-days-excluding-weekends/70578/4 "2024-02-08T05:12:19Z")

</div>

How can i use this ?  
In Java script code ?  
What values do i need to change ?

---

<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:** [February 8, 2024, 6:00am UTC](https://community.glideapps.com/t/calculation-of-days-excluding-weekends/70578/5 "2024-02-08T06:00:05Z")

</div>

It would be used in a Math column.

However, I’ve just realised that formula doesn’t quite do exactly what you are looking for. It adds a given number of business days to a start date, whereas you want to calculate the number between two dates. So it would need to be modified somewhat.

@tuzin is always up for a challenge. He might do that if you ask him nicely 😉

---

<div class="post-metadata">

**Author:** ![tuzin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/tuzin/32/86077_2.png) [@tuzin](https://community.glideapps.com/u/tuzin)\
**Post date:** [February 8, 2024, 9:24am UTC](https://community.glideapps.com/t/calculation-of-days-excluding-weekends/70578/6 "2024-02-08T09:24:41Z")

</div>

I’m 100% willing to try this a bit later. @FlorianA Please remind me about it if I don’t post in the next 24h 😅

---

<div class="post-metadata">

**Author:** ![FlorianA](https://avatars.discourse-cdn.com/v4/letter/f/ebca7d/32.png) [@FlorianA](https://community.glideapps.com/u/FlorianA)\
**Post date:** [February 9, 2024, 11:45am UTC](https://community.glideapps.com/t/calculation-of-days-excluding-weekends/70578/7 "2024-02-09T11:45:39Z")

</div>

Hi Tuzin,

Can you really help me ? Or it is a joke ?

---

<div class="post-metadata">

**Author:** ![tuzin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/tuzin/32/86077_2.png) [@tuzin](https://community.glideapps.com/u/tuzin)\
**Post date:** [February 9, 2024, 6:44pm UTC](https://community.glideapps.com/t/calculation-of-days-excluding-weekends/70578/8 "2024-02-09T18:44:59Z")

</div>

That would be a bad joke. I’m really eager to help

---

<div class="post-metadata">

**Author:** ![FlorianA](https://avatars.discourse-cdn.com/v4/letter/f/ebca7d/32.png) [@FlorianA](https://community.glideapps.com/u/FlorianA)\
**Post date:** [February 12, 2024, 7:31am UTC](https://community.glideapps.com/t/calculation-of-days-excluding-weekends/70578/9 "2024-02-12T07:31:28Z")

</div>

Oh great!  
I’m new to this forum  
I’ll explain what I need  
I need to put a start date in a “date entry” and an end date in another “date entry”, and I need to have a list of all the working days in a sort of “join list”.

Do you understand? And will you be able to help me?

---

<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:** [February 12, 2024, 3:06pm UTC](https://community.glideapps.com/t/calculation-of-days-excluding-weekends/70578/10 "2024-02-12T15:06:33Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/3/9/39fc4770da56392592c54f96fb1721c40c80f261.png)

My setup, tested in Safari, which has been problematic with Date functions in JavaScript in the past.

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/2/e234d92247c35ad4088f8b9485835d70771f0d91.png)

Date Start & End, user-specific columns, Date Pickers write into these columns.

Timezone: gotta have this to use in the JS function, since Glide seems to return UTC-based values in the JS function instead of returning it as is. Say I choose 15th Feb, it returns a Zulu timestamp of 5PM 14th Feb (I’m UTC+7).

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/b/3/b3e9f9683b7eec7e222e975564271e59536e6fdf.png)

Working Days JS: JavaScript column.

```auto
const timezoneOffset = parseInt(p3, 10);
const start = new Date(p1);
const end = new Date(p2);

start.setHours(start.getHours() + timezoneOffset);
end.setHours(end.getHours() + timezoneOffset, 59, 59, 999);

let currentDate = new Date(start);
const workingDays = [];

while (currentDate <= end) {
    if (currentDate.getDay() >= 1 && currentDate.getDay() <= 5) {
 workingDays.push(currentDate.toISOString().split('T')[0]);
    }
    currentDate.setDate(currentDate.getDate() + 1);
}

return workingDays.join(', ');

```

p1: Start  
p2: End  
p3: Timezone

---

<div class="post-metadata">

**Author:** ![FlorianA](https://avatars.discourse-cdn.com/v4/letter/f/ebca7d/32.png) [@FlorianA](https://community.glideapps.com/u/FlorianA)\
**Post date:** [February 13, 2024, 10:13am UTC](https://community.glideapps.com/t/calculation-of-days-excluding-weekends/70578/11 "2024-02-13T10:13:59Z")

</div>

Thank you very much for this answer  
I will test this as soon as possible

---

<div class="post-metadata">

**Author:** ![tuzin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/tuzin/32/86077_2.png) [@tuzin](https://community.glideapps.com/u/tuzin)\
**Post date:** [February 13, 2024, 10:50am UTC](https://community.glideapps.com/t/calculation-of-days-excluding-weekends/70578/12 "2024-02-13T10:50:17Z")

</div>

JavaScript column seems to be the only option to return a joined list of working days. I’d stick to the solution provided by @ThinhDinh

---

<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:** [February 13, 2024, 11:40am UTC](https://community.glideapps.com/t/calculation-of-days-excluding-weekends/70578/13 "2024-02-13T11:40:28Z")

</div>

It can also be done with a helper table, but that certainly isn’t a single column solution, and the maximum date range would be limited to the number of rows in the helper table.
