I want to create a Dataview list of all my notes in a calendar week. All my notes have the date property but also start with YYYY-MM-DD.
To show all daily notes I use this query from Kepanos vault
list
where
!contains(file.tags, "daily") and
contains(file.outlinks, this.file.link) or
contains(string(file.frontmatter), string(dateformat(this.file.day,"yyyy-MM-dd")))
sort file.ctime asc
limit 50
However, I now want to have notes that have the file name W1, W2, W3 etc but W1 is equal to week 44 because that is the first week on my journaling journey.
So what I would need is a query that somehow translates this.file = “W1” into where it would list all notes/files that have >=2023-10-30 AND <= 2023-11-05 in their names because that is how I am naming all my notes although they also all have a date property which is in DD.MM.YYYY though.
Is this possible with Dataview alone or do I need to use some more scripting possibly using JavaScript?
Things I have tried
I tried changing the daily note query into using file.weekyear and hoping it would work because I wouldn’t mind too much to change that query manually once per week.
list
where
!contains(file.tags, "daily") and
contains(file.outlinks, this.file.link) or
contains(string(file.frontmatter), string(dateformat(this.file.weekyear,"W44")))
sort file.ctime asc
limit 50
It seems to me that you are going the wrong way. It is a good idea to do the file names for the weeks according to the standards:
Week date representations are in the formats as shown in the adjacent box. [YYYY] indicates the ISO week-numbering year which is slightly different from the traditional Gregorian calendar year (see below). [Www] is the week number prefixed by the letter W, from W01 through W53.
So the names for the week files will be of the form for this week 2023-W45, for example.
Then you can use the following query in the week files:
LIST
FROM "log"
WHERE
dateformat(file.day, "kkkk-'W'WW") = "2023-W45"
SORT file.name asc
And here is a template to use for automatic creation using the template in Templater:
LIST
FROM "log"
WHERE
dateformat(file.day, "kkkk-'W'WW") = "<% tp.date.weekday("gggg-[W]WW", 0, tp.file.title) %>"
SORT file.name asc
For keeping a diary, I also recommend the following add-ons: Calendar and Periodic Notes. With these add-ons, you can automate the creation of daily and weekly notes and assign the appropriate templates for each period: daily, weekly, monthly, quarterly or yearly notes.
Thanks a lot. I used your solution to adapt it to my use case and I now have what I wanted.
I am now using this as my weekly note with the title/name of the file being “W1 2023-W44”.
To explain to other new users:
The WHERE clause is checking first for something like 2023-W44 in the file name. Then it is checking for a “created” property in the file with a date as the type. I am doing this because not all my notes have a date in their names so file.day alone wouldn’t catch the notes that I have created in a certain week. In addition, I am pre-fixing my notes with YYYY-MM-DD for those that have a high likelihood to result in duplicate names otherwise, like regular meetings, or recurring events.
---
tags:
- "#weekly"
aliases:
- W1
---
## Notes
```dataview
LIST
FROM "Notes"
WHERE
dateformat(file.day, "kkkk-'W'WW") = "2023-W44" or
dateformat(created, "kkkk-'W'WW") = "2023-W44"
SORT file.name asc