Help with obsidian task query?

Things I have tried


I would like to see a list of all the tasks I have completed in the last seven days, organized by date completed, newest first.

But first I need help just with the tasks I’ve done in the last week … I have this, but it doesn’t show anything:

done before one week

What I’m trying to do

I’m a novice too but try:

done after 1 week ago
sort by done

or (with \ removed):

TASK WHERE completed
AND file.mtime >= date(today) - dur(1 day)
SORT file.mtime Desc

Wow, that works, thank you!

One question though, some tasks don’t show a date completed for some reason (they simply have a check through it)

Without seeing the output I can’t say but I am speculating that you are seeing the name of a note e.g. daily note with the completed tasks beneath it?

Made some tweaks:

TASK WHERE completed AND completion >= date(today) - dur(7 day) SORT completion desc
1 Like

I’m trying to learn the syntax for all this, and as a simple test, wanted to create a query to see all tasks completed in the current day.

But this returns 0 results:

TASK WHERE completed AND completion = date(today)

But strangely, this returns expected results:

TASK WHERE completed AND completion != date(today)

TASK WHERE completed AND completion >= date(today)

Ok so this is odd (and thank you by the way!) –

It is showing tasks from one note, some of which I did yesterday and some of which I did today.

If I change the “>=” to just “=” it shows nothing, which I don’t understand.

Some simple questions:

  1. About completion, your tasks are annotated, i.e., with “:white_check_mark:YYYY-MM-DD” or “[completion:: YYYY-MM-DD]”?
  2. If (some) not, then the query use the file modified time. This is a problematic way, because if you made some changes to your file, then your task date changes too.

oops. mnvwvnm beat me to it.

I don’t know but I suspect when it is = to it is asking for the task that were completed at EXACTLY midnight today. FYI that completion field defaults to last modified time if the completion field is not populated. If you modified a task task today (and it was already completed) it will show as a result in this query.

I’m trying to figure this out myself but I believe you would populate it with inline metadata in your task:

[completion:: yyyy-mm-dd]

When I complete tasks, they are annotated like the first example you gave (the green and white checkmark)

So for it to work the way I want it to, I’d have to add metadata for each completed task?

Thank you both!!!

I don’t use (for now) tasks queries. But I follow the last dataview updates and the developer added some new functions to tasks queries:

If so, you are using another plugin to this auto-annotation. If it works correctly with dataview, I don’t know.

Yeah, I use the “tasks” plug-in.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.