# Working days in calendar month

**URL:** <https://community.fibery.io/t/working-days-in-calendar-month/698>\
**Category:** Ideas & Features\
**Created:** [May 12, 2020, 6:16am UTC](https://community.fibery.io/t/working-days-in-calendar-month/698 "2020-05-12T06:16:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adam](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/adam/32/334_2.png) [@Adam](https://community.fibery.io/u/Adam)\
**Post date:** [May 12, 2020, 6:16am UTC](https://community.fibery.io/t/working-days-in-calendar-month/698/1 "2020-05-12T06:16:30Z")

</div>

As a user I would like to calculate the number of working days in a month so I can effectively forecast revenue (amongst other things 😁)

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [April 12, 2022, 8:01pm UTC](https://community.fibery.io/t/working-days-in-calendar-month/698/2 "2022-04-12T20:01:24Z")

</div>

Useful?

> [@Show your Vacations Space?](https://community.fibery.io/t/show-your-vacations-space/1188):
>
> Hi all! wave I was wondering if someone could show their customized Vacations App, as I’m looking into the ways and ideas to make the standard one better. I have basic usage concerns, like “how do I set the state holidays for everyone, how do I manage paid and unpaid leaves, how do I make formulas omit the weekends” – and I thought that everyone using it has probably dealt with these concerns in some way. So I just wanted to ask: would someone want to show off their awesome customized Vacat…

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [November 1, 2023, 2:15pm UTC](https://community.fibery.io/t/working-days-in-calendar-month/698/3 "2023-11-01T14:15:04Z")

</div>

Quick follow up with another suggestion for how to calculate the number of working days in a month (or any period).

There is a [commercial API](https://api.workingdays.org/1.3/api-documentation) that supports queries for determining the working days in a given time period (taking into account weekends and public holidays for a specific country).

A simple script can therefore be used in an automation to send a query to the API which will return the number of days in a given period. As an example…

```auto
const fibery = context.getService('fibery');
const http = context.getService('http');

for (const entity of args.currentEntities) {
    const start = entity['Start'];
    const end = entity['End'];
    const countryCode = entity['Country'];

    const url = `https://api.workingdays.org/1.2/analyse?key=MYPERSONALKEY&country_code=${countryCode}&start_date=${start}&end_date=${end}`;
    const response = await http.getAsync(url);
    const respObj = JSON.parse(response);

    await fibery.updateEntity(entity.type, entity.id, { 'Working days': respObj.result.working_days.total });
    console.log(respObj);
}

```

You will need to pay for an API key (but you can test for free for the year 2013).

Note: the country codes used are the two letter codes which are currently included in the World template that Fibery has, so you could make things easy on yourself by leveraging that template.

There is no error handling in the code, so it will fail if the field values are empty, if the start date is before the end date, or if you try to calculate for a country that is not [supported](https://api.workingdays.org/api-countries), but hopefully the concept is useful to someone 🤞

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [April 29, 2025, 11:17am UTC](https://community.fibery.io/t/working-days-in-calendar-month/698/4 "2025-04-29T11:17:18Z")

</div>


