I’m having a weird anomaly when using multiple conditions in a dataview query for fetching tasks. My daily note’s format is as such: “Mon Mar 31 2025”
Here’s a query I use for my daily notes, which works great but the problem is that I’m going to lose tasks from the previous month since I’m only checking tasks contained within the month.
TASK WHERE
// if link to "do later"
contains(outlinks, [[🕒 Later]])
// if due or overdue
OR (due AND due <= date(this.file.name, "ccc LLL dd yyyy"))
OR (
// if the note has the "daily notes" category
contains(categories, [[📆 Daily Notes]])
// check if note contains the same month and if the date is lower to the current note's date
AND contains(this.file.name, split(this.file.name, " ")[1]) AND split(file.name, " ")[2] < split(this.file.name, " ")[2]
)
// if the note is not completed
AND (!completed AND status != "-")
GROUP BY file.link
I’m trying to fetch any tasks that are contained to a daily note prior to the current day’s note. So I tweaked my query to this:
TASK WHERE
// if link to "do later"
contains(outlinks, [[🕒 Later]])
// if due or overdue
OR (due AND due <= date(this.file.name, "ccc LLL dd yyyy"))
OR (
// if the note has the "daily notes" category
contains(categories, [[📆 Daily Notes]])
// TWEAKED LINE IS HERE:
// and if the note title converted to a date is less than or equal to the current note's title converted to a date
AND date(file.name, "ccc LLL dd yyyy") <= date(this.file.name, "ccc LLL dd yyyy")
)
// if the note is not completed
AND (!completed AND status != "-")
GROUP BY file.link
Somehow if I change the line:
AND contains(this.file.name, split(this.file.name, " ")[1]) AND split(file.name, " ")[2] < split(this.file.name, " ")[2]
to
AND date(file.name, "ccc LLL dd yyyy") <= date(this.file.name, "ccc LLL dd yyyy")
, every previous conditions are being ignored.
So for instance, any tasks that linked to [[🕒 Later]]
are being ignored using my new query but nothing has really changed except that I’m using a date comparison instead of comparing strings which is very peculiar.
I don’t know if that’s a bug or I’m just oblivious to some mistake I’ve made in the query. Anyone has a suggestion?
Thanks!
EDIT: Here’s another great example of the date clause taking precedence over the other clause even though it’s an OR
condition:
This shows the tasks linking to [[🕒 Later]]
TASK WHERE (
contains(outlinks, [[🕒 Later]])
) AND (!completed AND status != "-")
GROUP BY file.link
But this does NOT show them, only the task from previous daily notes show up:
TASK WHERE (
contains(outlinks, [[🕒 Later]])
OR date(file.name, "ccc LLL dd yyyy") <= date(this.file.name, "ccc LLL dd yyyy")
) AND (!completed AND status != "-")
GROUP BY file.link
When in fact, it should because it should show if something links to [[🕒 Later]]
OR if it is from a previous daily note.
EDIT2: If I replace the condition with AND file.cdate <= this.file.cdate
it does work. This is a good temporary fix but sometimes I might not create the daily notes in order (ie. I create tomorrow’s daily note but today)
So yeah, the problem is with this line: date(file.name, "ccc LLL dd yyyy") <= date(this.file.name, "ccc LLL dd yyyy")
… I even tried checking if the dates were not null, if the dates were of the actual type “date”, etc…
I’m so confused