What I’m trying to do
I’m trying to get a list of tasks completed on a certain day with dataviewjs (I do know how to do it in dataview, but I need dataviewjs to manipulate it further).
Things I have tried
After an extensive search, here is a minimal example that should be working:
- #task a task completed today
2025-01-13
const notes = dv.pages();
const tasks = notes.file.tasks.where(t => t.completion == dv.date("2025-01-13"));
dv.span(tasks.values.length)
The option for tracking tasks shorthand completion dates is on, and in the console I can see that the objects for the tasks does have the data as a datetime object.
I realize that the completion time object also contains hours and minutes and seconds, so the comparison in fact does not hold and should not work. I can’t see a better method built in, so I could just run separate comparisons for year and day and month. But I can’t find a way to even parse just the day/month/year out of the t.completion
object.
dv.date("2025-01-13").year
works to get the year out of the date object, but the same syntax (t.completion.year
) does not work for the object in the dataview task list. From inspection in the console, the datetime objects seem to store values in a subproperty called “c”, but t.completion.c.year
does not work either.
Does anybody know how to do this? Or is there a better way to just compare dates in the current dataview? I also tried:
t => dv.compare(t.completion, dv.date('2025-01-13') == -1)
where “-1” seems to be the value that dv.compare gives for matches on dates but not the rest of the timestamp. But that still doesn’t work.