How to use dataview to filter Daily Notes based on date in filename

Hi everyone,
I want to use dataview to create a list of notes from my Daily Notes that fall between two dates.

What I’m trying to do

I work in an education setting, and I want to filter my notes so that only the notes from the current term will be displayed.

My daily notes are named in the following format:
YYYY-MM-DD dddd
eg, “2024-08-01 Monday.md”

How do I use the filenames to display only the daily notes between two specific dates?

I don’t want to use the file creation time because my notes might not be created on the date of the filename.

For example, for the upcoming term I would only want to display notes that are from Jan 29th - Apr 12th.

Things I have tried

In the example below I’m trying to display notes from Jan 6th onwards as a test. Once this works I’m sure I can filter between two different dates. I’ve tried using the date function in dataview as follows:

```dataview
TABLE
FROM "Daily Notes"
WHERE date(file.name, "YYYY-MM-DD dddd") > 2024-01-06
``` (for some reason I need to enter text here to display the closing ``` correctly in this post).

However, this gives me the following error:

Dataview: Every row during operation ‘where’ failed with an error; first 3:

  • Can’t handle format (YYYY-MM-DD dddd) on date string (2023-01-05 Thursday)
  • Can’t handle format (YYYY-MM-DD dddd) on date string (2023-01-06 Friday)
  • Can’t handle format (YYYY-MM-DD dddd) on date string (2023-01-09 Monday)

Thanks in advance!

The date conversion fails because one of the date elements is localised, and that it can’t convert back to numbers. However since you’ve got the full date within the title already, you can use file.day to access this date. No conversion needed. :smiley:

file.day will pick the date if found in the title, or from a date property in your file. So in your case it’ll use the title directly.

PS: you can enclose queries in a forum post by surrounding everything with four backticks. That’ll escape the normal code fences. Like in:

````
```dataview
LIST file.day WHERE file.day
```
````