I would like to calculate between the current date and a date in note, trying to get the year in a new collom in bases.
Can bases calculate dates?
I have a property in note which is date there is the date of a scheduled agenda, now i would like to calculate this date with the current date and i want the output in years.
Example i have a note from 2005 (passing my dad ) now its 2025, can bases calculate and show now 20 years in a collom?
It could be handy for birthdays (see the age ) or people who passed away.
thank you
Things I have tried
i not so very good in formulas, trying to search a lot in this forum , found
(date(propery.date) -date(now()))
If you copy and paste the text below into a new note, does it help as an example Base for you to work with?
---
dob: 1934-06-11
dod: 2009-08-25
---
```base
formulas:
age: today() - dob
years since death: today() - dod
age when died: dod - dob
properties:
formula.age:
displayName: age today
views:
- type: table
name: Table
filters:
and:
- "!dob.isEmpty()"
order:
- file.name
- formula.age
- formula.age when died
- formula.years since death
sort:
- property: formula.age when died
direction: ASC
columnSize:
file.name: 164
formula.age: 135
```
Unfortunately, this isn’t as precise as I hoped. The date gets rounded when it does toString(), which means that for ages, it’s wrong for the latter half of the year, reporting a year older than actual. And there doesn’t seem to be a way to change how the toString function rounds…? It would be lovely if I could call floor() on a date or something, but that’s not available, which means something more complex and less pretty looking is needed for accuracy…
display a full, detailed duration in Bases (e.g., “4 years, 11 months, 25 days, 13 hours”) or pick and choose your duration units – forum post
calculate time between two dates with before-and-after date validation – (same link as above)
list upcoming periodic events and duration (e.g., birthday reminders, anniversary calculations, ages) while accounting for before and after the current day of the year – on Discord