I want to include tasks that have the tag #{weekday} depending on the date in the file name. Essentially, this should be possible using:
task
from "path to my daily notes"
where contains(tags, "'#" + this.file.day.weekday)
However, this.file.day.weekday gives the weekday back as a number (1: Monday, 2: Tuesday, …), but I really would like it to give me the weekdays as actually written-out days. Essentially, I would like to use something like .format("dddd"), but this does not work! There has to be some easy workaround or fix for this, but I couldn’t find anything in the documentation.
Also, another minor issue is that this.file.day only seems to work if the title is in the format YYYY-MM-DD, but I would prefer DD-MM-YYYY. I thought I could fix this by changing the date format, but that didn’t help. A workaround I tried for that issue is to use date(this.file.name) to make it into a date object. But apparently, the function date() also expects arguments of the form YYYY-MM-DD.
By the way, I would like to not add a property with the date in my daily note since that feels really redundant and would like to make it work with just the title.
To properly set file.day, you do need to either have an ISO date somewhere in the file title, or in a property named date. That’s just the way it is defined.
You could get a date from a text in “DD-MM-YYYY” format through using the date(text, format) function. Assuming you start your file title with that text, you should be able to do something like date(substring(file.name, 0, 10), "dd-MM-yyyy") to get the date.
Personally I prefer to add the date property.
Given a proper file.day, you should be able to dateformat(file.day, "cccc") (or “ccc” of you prefer the abbreviated variant).
@NickNordwald, I think the following is something along the lines of what your looking for based on my best guess of what your task note structure would look like. (see example notes Note 1, Note 2, Note 3, and Note All). Given a note with a file name 18-11-2024, which follows your preferred naming convention and is a Monday…
18-11-2024
```dataview
TASK
FROM "path to my daily notes"
WHERE contains(tags, "#" + dateformat(date(this.file.name,"dd-MM-yyyy"),"cccc"))
This worked like a charm and also something interesting is happening: I was super confused why this didn’t work at first and after displaying dateformat(date(this.file.name,"dd-MM-yyyy"),"cccc") I noticed that it gives me the weekdays back in German. I have no idea why it does this (I mean I do live in Germany but I have everything in my Obsidian set to english). But using the German weekdays doesn’t bother me at all so thanks again!