I just went down this rabbit hole.
Working (wrestling?) with vibecoding in Copilot, here’s what ended up working for me.
-
I created three separate fields in the YAML frontmatter: BYear, BMonth, BDay. All number type.
-
In bases, create a formula property for “CurrentAge”, “UntilNext”, and “Birthday”.
-
The Birthday is a single-column visual of the birthday data (for example, shows xxxx-02-11 for a birthday in my people notes that have a birthday on 11th Feb but i don’t have year info).
-
CurrentAge shows the age of that person as of today, but only if we know their year as well (obviously). This adds one if the birthday is already passed.
-
UntilNext is the birthday countdown and only uses the BMonth and BDay values. It also rounds the value down to avoid lengthy decimals.
Here are the formula needed for each:
Birthday
(if(BYear, BYear, “xxxx”)
“-”
if(BMonth,if(BMonth < 10, “0” + BMonth, BMonth),“xx”)
“-”
if(BDay,if(BDay < 10, “0” + BDay, BDay),“xx”))
CurrentAge
if(BYear,today().year- BYear- if(date(today().year+ “-”+ if(BMonth < 10, “0” + BMonth, BMonth)+ “-”+ if(BDay < 10, “0” + BDay, BDay)) > today(),1,0),“”)
UntilNext
if(BMonth && BDay,((number(date(today().year+ “-”+ if(BMonth < 10, “0” + BMonth, BMonth)+ “-”+ if(BDay < 10, “0” + BDay, BDay))+ if(date(today().year+ “-”+ if(BMonth < 10, “0” + BMonth, BMonth)+ “-”+ if(BDay < 10, “0” + BDay, BDay)) < today(),“1y”,“0y”))- number(date(today()))) / 86400000).floor(),“”)
(sorry if the formatting is not as it should be/expected - i had a whole lot of trouble getting my head around how to get this to work in the post).
Here’s what that renders like: