Skip to content

Instantly share code, notes, and snippets.

@dsebastien
Last active August 13, 2025 09:39
Show Gist options
  • Save dsebastien/2cdc1390b85d69aba9fbf205169e329b to your computer and use it in GitHub Desktop.
Save dsebastien/2cdc1390b85d69aba9fbf205169e329b to your computer and use it in GitHub Desktop.
Obsidian Base Formula that calculate people's age (current, at death, died x years ago, ...)
if(date_of_birth && !date_of_birth.isEmpty(), if(date_of_death && !date_of_death.isEmpty(),"Died at "+ (if(/\d{4}-\d{2}-\d{2}/.matches(date_of_death.toString()), date(date_of_death),date(date_of_death.toString() + "-01-01")) - if(/\d{4}-\d{2}-\d{2}/.matches(date_of_birth.toString()), date(date_of_birth), date(date_of_birth.toString() + "-01-01"))).years.round() + " (" + (date(now()) - if(/\d{4}-\d{2}-\d{2}/.matches(date_of_death.toString()), date(date_of_death), date(date_of_death.toString() + "-01-01"))).years.round() + " years ago)", (date(now()) - if(/\d{4}-\d{2}-\d{2}/.matches(date_of_birth.toString()), date(date_of_birth), date(date_of_birth.toString() + "-01-01"))).years.round()), "")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment