Well, it’s possible but really clumsy due to the restricted syntax of Dataview. I wish we had “real” SQL syntax and/or JS.
Let’s say we want a “upcoming birthdays” table for the next two months from now. Crossing year boundaries must be possible (i.e., if you are in December, you also want the January birthdays), and the list sorted. Also, you want to show what birthday it will be.
Warning: This is not elegant, rather clumsy, relies on numerical computations and lots of repeating calculations! This isn’t production-quality code, but just a proof of concept.
You will have to change the desired duration to show in three places in the dataview code block (look for dur(2 months)
).
### Upcoming Birthdays
Here are the upcoming birthdays for the next 2 months (until `=date(today) + dur(2 months)`).
table birthday as "Birthday", choice(
date(today).month*100+date(today).day = birthday.month*100+birthday.day,(date(today)-birthday).year,(date(today)-birthday).year+1) as Turns
from "People/Friends & Family"
where file.name != this.file.name and
choice(date(today).month*100+date(today).day > birthday.month*100+birthday.day,
(date(today).year+1)*10000 + birthday.month*100 + birthday.day,
date(today).year*10000 + birthday.month*100 + birthday.day) <= (date(today) + dur(2 months)).year*10000+(date(today) + dur(2 months)).month*100+(date(today) + dur(2 months)).day
sort choice(
date(today).month*100+date(today).day > birthday.month*100+birthday.day,
(date(today).year+1)*10000 + birthday.month*100 + birthday.day,
date(today).year*10000 + birthday.month*100 + birthday.day)
It will look like this:
Have fun! (And hope for a combined SQL and Javascript engine.)
If anyone knows how to simplify this horrible code (and retain full functionality), please let us know!