Photo by Landon Martin on Unsplash

Coda the next working day

when your weekend is not a Saturday and Sunday

Christiaan Huizer
4 min readMay 22, 2023

--

In October 2022 I already wrote in a blog about the next working day in a context that a working day can have 1 up to 7 days. The standard of 5 working days, is however common, not practical as hard coded value in a function.

In the community the question came on how to use the function Workday() in case your weekend is on Friday & Saturday

The sad story is that this function does not help you. However as shown in a previous blog, we can lower the floor and get a higher ceiling when we use proven patterns. These patterns are based on how the Coda Formula Language functions. Long story short:

  • everything is a list
  • items in these lists have properties (at least one, the position in the list)
  • items in a list are sorted (the copy paste you do from a spreadsheet is a sorting)
  • items can be used in a filter
  • items can be evaluated

There is more to say, but these principles are frequently observed.

The List Logic

When you have a date you have a list with one item. When you want to have the next working date you need a list with at least two items (date and date plus one). When this list with two items does not contain the next working day, you need a longer list to have more options.

When you are sure there is always a working date per week, you take 7, when you work at least once per month you take 31 and per year 365.

The number does not really matter, the calculation remains fast because we are not going to print the intermediate steps on our screen. We print (you can also read ‘show’) only the outcome, which is one date. The list (no matter how long) is a virtual list living in the memory of your computer.

Creating a list and filter on properties

We create a list using the function Sequence() because dates are numbers

create a list of numbers

Dates have various properties, we need the one relating to the weekday, which has the appropriate name Weekday(). In this blog we assume Sunday is day number one. The function below shows people work From Sunday till Thursday, Friday & Saturday (days 6 and 7) are non working days.

Sequence(thisRow.theDate + 1,thisRow.theDate + 7).Filter(CurrentValue.Weekday().Contains(1,2,3,4,5))

This results in a list of dates shown as numbers. We only need one, the first one and thus we add First() and we turn this number into a human friendly date format:

the result

The pattern

we created a list with some dates using Sequence(), we Filter() on the property Weekday() and we took the First() value, this one we formatted into something human friendly.

This patten returns often and even if you do not fully understand it, you should try to integrate it in your work, it helps to speed up your understanding of how to Coda.

This logic can be applied in a context people only work certain days a week and take vacation etc. In other blogs I wrote solutions to meet complex demands. This is an easy one, step zero that warms you up.

My name is Christiaan and I support SMB with calculations (budgets and — Human Resource — planning) and I prefer using Coda to get the job done. More about me below.

I hope you enjoyed this article. If you have questions feel free to reach out. Though this article is for free, my work (including advice) won’t be, but there is always room for a chat to see what can be done. Besides you find my (for free) contributions to the Coda Community and on Twitter.

Coda comes with a set of building blocks ー like pages for infinite depth, tables that talk to each other, and buttons that take action inside or outside your doc ーso anyone can make a doc as powerful as an app (source).

Not to forget: the Coda Community provides great insights for free once you add a sample doc.

--

--

Christiaan Huizer

I write about how to Coda . You find blogs for beginners and experienced makers. I publish about 1 / week. Welcome!