I am trying to include a dataview query in each of my daily notes to show the meeting notes for meetings that take place on the day in question. Here is my test query:
LIST file.day FROM "Meetings" WHERE file.day = date(2023-12-18) SORT file.day ASC
The meeting notes are saved in a folder called “Meetings” with files named like so: 2023-12-18 Project launch
The query is almost there. Where it fails is in the date comparison logic–it returns nothing, rather than the single meeting on that day. I’m sure that I am missing something small but critical…
Things I have tried
I have tried various near-neighbor queries. For example, changing the file.day = date(2023-12-18) to file.cday = date(2023-12-18) works as expected. However, I don’t always create meeting notes on the day of the meeting, so I really want to pull based on the date in the meeting title.
OK, I’ve figured it out. My original query works fine except on notes where the date/time YAML parameter actually saves a time. For example, a file named 2023-12-18 Project Launch with this frontmatter is picked up by file.day = date(2023-12-18):
---
date: 2023-12-18
---
…but this fails to be picked up:
---
date: 2023-12-18T11:00:00
---
My best guess is that in the latter situation the more specific date with a time included populates file.day and therefore the equality test fails, because a date is not the same as a date at a specific time. Poking around in the documentation, I found the striptime() function which makes this query work:
LIST FROM "Meetings" WHERE striptime(file.day) = date(2023-12-18) SORT file.day ASC
And an even better formulation for use in a daily note is:
LIST FROM "Meetings" WHERE striptime(file.day) = striptime(this.file.day) SORT file.day ASC