Convert series to date while skipping weekends

Motivation

I’m a teacher and I use similar lessons year after year. It’s useful to visualize upcoming lessons by date. The lessons are ordered by instructional days, and every year they have the dates have to be adjusted.

What I wanted was to create a formula to convert the series information into dates. I figured it out and thought someone else might find it useful.

date("2026-02-23") + (Day.toString()+"d") - "1d" + ((2*((day-1)/5).floor()).toString()+"d")
  • First term: start date
  • Second term: formatting the series so I can add a day
  • Third term: offset so that the day 1 isn’t the day after my start date
  • Fourth term: this skips the weekends. It assumes the start date is a Monday, but you can change that by changing the -1.

Here is the result. Notice that the date skips 2 days every 5 days:

1 Like

This is for Bases?

Nice job!

No reason to fix a thing that ain’t broke. I just want you know about a few simplifications Bases formulas let you make. For your future base building.

This formula does the same as yours:

date("2026-02-23") + ((Day - 1 + (2 * (day - 1) / 5).floor()) + "d")

How come:

Using + with a string automatically stringifies the other operand, so no need to use .toString() in those cases.

You can do all of your mathematical operations together then tag a “d” at the end to make a single duration.

Seeing what you successfully figured out makes me think you probably did think to combine the math but may have run into issues. If so, then the secret sauce is in the parenthetical groups. The goal is “date + duration”, and duration is “number and unit”, and number is “a bunch of calculation”, so the grouping breakdown is “date + (( a bunch of calculation ) + unit )”.

An ungrouped “date + a bunch of calculation + unit” will fail because—coming full circle here—the + operations turn the first two operands into strings.

Thanks for the feedback. The inefficiency comes from a combination of not being fluent with the syntax behavior and the fact I tacked the weekend skipping after the fact.