How to auto populate birthdays in Daily Notes

Things I have tried

I’ve looked thru the Dataview docs and the dates format reference on momentjs.

What I’m trying to do

I keep notes on people important to me (one note per person) that includes their date of birth in the frontmatter, like this:

dob: 1990-12-01

Now, in my daily notes template, I am trying to add a query that will automatically tell me if someone has a birthday on that date. Here is what I’ve got so far:

LIST
FROM #Person 
WHERE dob = date({{date:YYYY-MM-DD}})
SORT file.name ASC

This works only if the person’s date of birth is exactly the same as the Daily Notes date, which isn’t what I need. (Side-note, I used the date template rather than date(today) because I often create Daily Notes in advance to its day.

I tried to get the query to only return if the month and day matched, like this:

WHERE dob = date(.*{{date:MM-DD}})

but that didn’t work.
So, my question is, can anyone help me figure this one out?

Thanks all

Hi,

I don’t understand very well the way you introduce the date via template: {{date:YYYY-MM-DD}} doesn’t gives you the today date, i.e., the date when you insert the template?

But, ignoring this doubt, you can use one of this expressions in WHERE:

  1. WHERE date(dob).month = date({{date:YYYY-MM-DD}}).month AND date(dob).day = date({{date:YYYY-MM-DD}}).day
  2. WHERE dateformat(dob, "MM-dd") = dateformat(date({{date:YYYY-MM-DD}}), "MM-dd")

In both cases, the logic is check the match only to month and day.

1 Like

That’s awesome, thank you for your help!

To answer your question about introducing the date via template, when i use {{date:YYYY-MM-DD}}, it generates the date on which the note is assigned to.

Well, I don’t use Daily Notes (yet :slight_smile: ) and if I use the syntax {{date:YYYY-MM-DD}} in template when insert it in any note I get the moment date.

This is the reason for my doubt. Perhaps with Daily Notes plugin (or via Calendar plugin) the behavior it’s different.

BTW, dataview has an implicit field - file.day - that works if file has a date in its title (of form yyyy-mm-dd or yyyymmdd). If the case you can use:

WHERE dateformat(dob, "MM-dd") = dateformat(this.file.day, "MM-dd")
or
WHERE date(dob).month = this.file.day.month AND date(dob).day = this.file.day.day

Yes, I should have clarified: I’m using the Calendar plugin as well as the Daily Note. So when I click on the day I wish to open in the Calendar view, that daily note pulls the template with the {{date:YYYY-MM-DD}} syntax and assigns it the correct date. Tbh, I don’t know how it works.

Thank you for the extra info about file.day!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.