View of tasks due on file.name

I’ve spent several hours on this. I’ve been through the Task and Dataview documentation. My first point of confusion is whether I should be using Dataview or Tasks queries.

My main question is how to create a simple query for listing tasks whose creation|due|cancelled|etc… date equals the date of the filename the view is in (format YYYY-MM-DD.md).

The bit I can’t make work is filtering on the file.name as a data.

This is all I’m trying to do:

select tasks
from folder "folder/path"
where status in (created, due, cancelled, completed)
and some_date_formatter?(file.frontmatter.created, "YYYY-MM-DD" = file.name

There’s a free pack of BubbaLicious (mostly full) for anyone that can help me.

Thanks,

Harry

After a few more hours of digging through the docs, I came up with these two mostly working examples.


Incomplete work tasks due

TASK 
FROM "work"
WHERE !completed 
AND due
AND due <= date(file.name)

Completed work tasks

TASK 
FROM "work"
WHERE completed
AND completed = date(file.name)

Given a proper filename, which you seem to have, you can use file.day to get the date directly.

I did try that, but couldn’t seem to get it to work.

There are too many options for these queries :slight_smile:

And I only just realized that all the frontmatter properties are imported into the global namespace in dataview.

I wanted to try to see all the data available to dataviews by inspecting in devtools, but I couldn’t get dataviews to stop at breakpoints. I’d love to be able to run this stuff in a debugger.

Here are few options related to debugging queries.

  • For a non-task query I’m often using extra columns in a TABLE format. For this to work related to a TASK query you’ll need to do FLATTEN file.tasks as task and change stuff like completed into task.completed. Slightly more writing, and a little painful when going back and forth between the TASK and the TABLE query, but very useful
  • If in the file holding the variables you could do stuff like `$= dv.span(dv.current())` to list all information related to that file, or the slightly more complex: `$= const all = dv.current(); delete all.file; dv.span(all);` to show all information not including the file information. The latter is not so much information

Regarding debugging of Dataview within Obsidian you could open the Developer tool pane, and then in your note do something like:

```dataviewjs
debugger
console.log("Hi there");
```

This should open the debugger in your custom script, but using the stack trace you can use that to “enter” the code of dataview within the plugin:dataview sources window. Navigating within this source code, and setting breakpoints is not for the faint of heart though. :slight_smile:


Here is an example transformation of your last query:

```dataview
TABLE task.completed, file.day, date(file.name), file.name
FROM "work"
LIMIT 20
FLATTEN file.tasks as task
```

Here I focus on looking at why/if the date(file.name) differs from file.day. Note that for starters I remove the WHERE clause, and only look at the first 20 entries. As debugging continues I build up the WHERE clause to match what I really want.

Note that you could add a column in the table like completed = date(file.name) to see the truthy value of that statement.