Next Birthday in Coda

something simple going wrong easily

Christiaan Huizer
4 min readMay 7

Below an easy to follow but nevertheless wrong solution to get the next birthday.

mistaken outcome

As you see, I make again use of the base function Date() as I did in my previous blog on dates, it avoids complications.

Although all looks fine, the provided code snippet does not deal with one exception: the leap year as you see below.

mistaken outcome

The year 2024 is a leap year and thus the outcome should be Feb 29, 2024. Instead it moved the year by one based on the birthday this year which is indeed March 01, 2023. Coda moves the date with one, because Feb 29 does not exist in 2023. When we add one year to this year, the outcome is both logical and mistaken.

What is a leap year?

A short intermezzo on the logic of leap years. In technical terms the year should be divisible by 4 or 400 but not by 100. In Coda terms:

getting the leap year

You can compare this syntax to what a Coda employee Justin Hales wrote a few years ago. Do you see the difference?




),"Leap Year", "NOT a Leap Year")

The same outcome with another way of writing (syntax). My guideline is that code should be easy to read and thus be understood. Only when we can read out loud what is happening, we are on to something. In a next blog I explore in more detail the meaning of a lower floor.

Although 29 feb can only exist in a leap year, the question is, do we need the leap year logic? The good news is, we don’t and that is because what I wrote earlier. In the Coda formula language the date is moved ahead by one when the date looked at, is not present. We take advantage of that behavior and shorten our formula using a simple solution.

The simple solution

The final solution is actually rather simple. We generate the birthday as Date() and compare it with the date of today. Crucial is the > operator.

No complexity with leap years. It is a short and elegant solution that keeps the base logic intact and does not work with unnecessary assumptions. It also works with EU formatted dates.

Below how to get the age:

Get the age

Edit, Oct 27 , 2023

I added the blog I posted related to Sign() permitting a compacter logic without WithName() ⤵️

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.

Interested in a two way sync solution?

Check out this blog: it is easy and goes fast



Christiaan Huizer

I write about Mainly on Coda AI and interesting HR planning challenges. You find blogs for beginners and experienced makers.