Obsidian Tasks Series, Part 4 - Querying Your Tasks

Welcome back to this mini series on the Obsidian Tasks Community Plugin. I’m walking you through all of the experimentation and learning I’ve done to begin using the Obsidian Tasks Community Plugin. I hope that it helps you create a task management system in Obsidian that works for you. There is a YouTube video to accompany each article in this series so feel free to check that out. The videos and and articles roughly parallel one another.

As we begin, here is a rough plan for the series so you can see where we are and what’s coming next. As we continue in the series, I’ll come back and update links to future articles so you can easily navigate between the parts of the series.

In the first three articles and videos, I've created a few simple queries to demonstrate and make points. In this article and video, we're going to dig into how to construct queries. This is an important enough topic that I've divided it into two parts (and this first section is still VERY long - so grab a drink as you dig in here). In this first part, we'll focus just on creating queries. In the next installment, we'll focus on how to edit and customize queries as well as on how to use tasks within queries.

The All Tasks Query

The simplest of all Obsidian queries has absolutely nothing in it. But, it’s perfect as it gives us the framework for all future task queries. Here is what a task query looks like. This one, being empty, will return all tasks in the vault.

```tasks

```

A word of caution - running an empty query like this in a vault full of tasks can take a long time to run. It’s a very good idea to run this only in a vault with a few tasks in it. You may also nest a query like this in a header or a callout that can be folded so that it won’t mess with the page loading on an ongoing basis.

The Obsidian Tasks Query Quick Reference Guide

As noted above, my aim with this entire series is to teach you how to build a task management system that works well for you. As such, there is an indispensable reference that you’ll want to keep handy - the Obsidian Tasks Quick Reference Guide.

The guide has five columns - status, sort, group, display, and scripting. The text you see in each of the boxes is the exact text you use in queries to work with that specific kind of item. We won’t be talking about scripting in this series. If you want to dig in on your own, feel free to explore that part of the broader Obsidian Tasks user guide.

Documenting Your Queries

I am a firm believer in documentation. So, before we actually get into significant query writing, I want to teach you the syntax for adding comments to an Obsidian tasks query. The syntax is quite easy - you just add a pound sign and a space and then start typing your comment. If a comment extends beyond a line of text, that's okay. Just keep typing. As long as you don't hit enter, anything after the pound sign will be read as a comment.

Let's take a look at what that looks like in practice on the next simplest kind of query - the not done query:

```tasks
# This is a comment. Notice that there is a space between the pound sign/hashtag and the text of the comment. A comment can also extend for multiple lines as long as you don't actually hit enter/rturn. Once you do that, the comment ends.

not done

# This query will return all incomplete tasks
```

I’ll be demonstrating good commenting practice on every query moving forward.

Done, Not Done, and Statuses

In my current vault, if I run that first empty query that will return all tasks in my vault, it returns over 1500 tasks. Looking at a list that long makes my brain go numb. Even the query of just tasks that are not done returns over 900 items. So, we need to get skilled with displaying just the right set of tasks in a specific context to actually allow us to focus and get work done.

Before we dig in completely, we need to look back for just a moment to #Obsidian Tasks Series, Part 2 - Task Statuses. In that article/video we introduced several additional task statuses to our vault. I used one of those - the Quote for a couple of sample pages in the demonstration vault. Here is a reminder of what that quote styling looks like in that vault.

Obsidian has five different task status types - todo, done, in progress, cancelled, and non_task. In queries, Obsidian Tasks treats done, cancelled, and non_task as done. Todo and in progress are considered not done. So, if I query that demo vault for all not done tasks, the quotes will not appear in that query.

Speaking of those quotes - and special status types in general - let’s create a query that finds all of those quotes.

```tasks
# This query will return all of the tasks that have a status of Quote

status.name includes quote
```

If you can’t remember the names of the specific statuses, you can always see them in the Tasks Community Plugin or in the Create/Edit Task Modal (just click the status button in the bottom third of the modal).

In the demo vault, I have two different pages with notes - one for Laura Vanderkam’s 168 Hours and another for Bob Doto’s A System for writing. Let’s focus our query even more and just display the quotes from Bob’s book.

```tasks
# This query returns all tasks with the status of quote from Bob Doto's A system for Writing note. 

status.name includes quote
path includes A System for Writing by Bob Doto
```

This is also a good time to mention that “path” as we used above would return any note in your vault that includes A System for Writing by Bob Doto anywhere in its path. Maybe you put lots of different notes in a folder named that. It would look at all those notes and return the quotes. Path is a powerful variable for letting you craft queries that work for you. Path is also an important tool for limiting queries. We’ll talk about this more in the next video when we talk about using the Obsidian Tasks Community Plugins settings to exclude the templates folder from all queries using the global query in the plugin settings. 

Grouping and Sorting, Part 1

On the Obsidian Tasks Quick Reference, you’ll notice that there are columns both for grouping and sorting. Here is what that looks like for the statuses of done and not done.

Grouping by status will divide your tasks into groups by done or not done. If you want to get more granular, you’d use the next option which is to group by status.name.

Here is the simplest of queries that will group everything in the vault by status.

```tasks
# This query returns all tasks, grouped into two groups of done and not done

group by status
```

So far we’ve just used one command in our queries, but we can use multiple commands to further narrow down the results that are returned to us.

Let’s say I want to look ONLY at tasks that have a due date and sort the tasks by due date. And, I only want to see tasks that are not done. Here is what that query looks like.

```tasks
# Returns all incomplete tasks that have a due date assigned. The resulting list is sorted by due date.

not done
has due date
sort by due
```

I use the has option quite a lot in my system as I’ll sometimes jot out the tasks in a project I have in my head in a note for that project. I’ll include them as tasks because I have them segmented in my vault in a specific way. However, I’m not committed to them right now so they have no due date. Using the has option filters out all of those tasks that don’t have a due date.

Hiding and Putting Queries in Callouts

Earlier, I mentioned that you could put a task query inside of a callout. Callouts and headings are two ways you can “fold” text so that it does not always have to be displayed on the screen.

When it’s folded up, the callout looks like this:

When you click the right arrow to the right of the words December 4, the callout opens displaying the query.

Using a callout in this way is a great way to add visual interest to your page and give you a way to tuck tasks away out of sight if you wish to do so.

All of this can be added in an automated way using the Templater Community Plugin - and in a slightly less customized but still automated way with the Templates Core Plugin. I’m going to do a whole series on those plugins as well. For now, though, let’s stay focused on what all the syntax looks like for this callout and the task query.

> [!Todo]- Due December 4
> ```tasks
> # This query is embedded inside of a callout that is defaulted to collapsed status. Note the minus sign after the callout type. If you want it to default to open, add a plus sign. 
> not done
> due on 2025-12-04
> # I opted to hide the due date since the callout title tells us all of these are tasks due on December 4
> hide due date
> ```

First of all, if you’re unfamiliar with Obsidian Callouts, you can check out the Obsidian documentation on callouts and an article I wrote a while back about all the various ways you can automate adding callouts to your notes. The basic structure of a callout is a forward arrow, the callout type in brackets with an exclamation mark and then a title for the callout. I like to add a minus to make sure that my callouts default to folded.

After you add the callout syntax, each line of the callout also begins with a forward arrow. Beyond that, you simply add your query as normal. In this query, I opted to use the hide function to hide the due date since the callout already said what the due date was for these tasks.

Grouping and Sorting, Part 2 - Filename and Path

Let’s look at a few more options for grouping and sorting. We’re going to use these to build a very simple tasks management system that groups by file name and sorts by due date.

```tasks
# This query will present a list grouped by filename of all tasks (sorted by due date) that are not done across the vault

not done
sort by due
group by filename
```

That version will return tasks from all across the vault. However, you can narrow this down to specific paths, folders, and more. This option will pull tasks from ONLY tasks in a folder named Projects that is located in the root of the vault.

```tasks
# This query will present a list of tasks from notes in the Projects folder grouped by filename of all tasks (sorted by due date) that are not done across the vault

not done
folder includes Projects
sort by due
group by filename
```

If you are super diligent about adding tasks ONLY to project pages, this is another super simple project management system that could work for you. You could further refine that to show only tasks due in a certain period of time - let's look at that next!

Using Dates in Queries

Obsidian Tasks has powerful built in date functionality. The Plugin can easily pull lists of tasks in groupings by last, this, and next for the week, month, quarter, and year.

Here is a query for tasks that are not done and are due this week.

```tasks
# returns all incomplete tasks that are due this week

not done
due this week
```

You can also search by a specific week number of by a specific month. Here is a query for tasks due in Week 49 of 2025.

```tasks
# returns all incomplete tasks that are due in Week 49 of 2025

not done
due in 2025-W49
```

If you use completed date in your vault, you can also search for tasks by when you completed them. I have this as a standard query on my daily note so that I can see all tasks done on that date (using an auto fill from the Templates or Templater plugin). Here is a sample query for tasks that you completed in December 2025.

```tasks
# completed tasks from the month of December 2025
done in 2025-12
```

We can also find tasks that are overdue. If you just want overdue tasks, the query below will work. If you want to have overdue tasks mixed with today’s tasks, you can use on or before today.

```tasks
# all overdue tasks
not done
due before today
```

Custom Date Ranges

If you want to look at a custom date range, you can do that by putting the dates together. This can be useful in a wide array of circumstances. If I’m going to be traveling for a few days, I’ll run a query for those days a few days before to make sure everything has been properly dealt with for the time period while I was gone. Here is an example query that will find all incomplete tasks due between December 1 and 4.

```tasks
# returns incomplete tasks that are due between December 1 and 4, 2025.
not done
due in 2025-12-01 2025-12-04
```

Using Logical Operators - AND, OR, and NOT

You can use logical operators like AND, OR, and NOT with different query options.

It’s critical that when you use logical operators in queries, that they be in all caps!

These open up an incredible range of power for your queries. That said, as a person who excels at making order out of chaos, I realize that I often make chaos so that I can use that superpower and then organize the chaos. So, take a word of advice from me. Keep your task system as simple as possible. We'll discuss that in more depth in the upcoming video on building your own task management system.

Let's take a look at how to use logical operators using tags and path options. Let me quickly show you a couple of ways I have added tasks to this vault.

First, here is a daily page from this vault.

Notice that I've highlighted all of the tasks that have the tag ar/ChurchFinances just to make them stand out for purposes of the video and article. You can even query tasks for those that are highlighted (or use other markdown) which I'll demonstrate in the video attached to this article.

These tasks in the daily note are ones I might add in the course of the day as I work so that I don't need to leave that page to go find the page I need and risk killing my focus. I can just add the task with the appropriate tag and have confidence it will get picked up in my queries. This tag method for a specific project or area is what I use today in my system and what I plan to use in my system going forward. That said, when we talk about backstopping your task management system in a future video, there are other things you might consider querying on from time to time to make sure that nothing is falling through the cracks of your system.

While I do use the tag method in my daily notes, I prefer to enter recurring tasks and tasks that are specific to a project to that specific project page when I can. This allows me to easily keep all the context together. So, let's look at the actual page.

For demonstration purposes, let me show you a query you can use anywhere the vault to put these two lists of tasks together.

```tasks
# Returns all incomplete tasks that contain the tag #ar/ChurchFinances OR that are in the file [[Church Finances]]. It sorts them by due date.

not done
sort by due
(path includes Projects/Church Finances) OR (tags include #ar/ChurchFinances)
```

That query returns both sets of tasks, now sorted together by their due date.

Querying based on text in the description

You can also look for specific text in the task description. I use this regularly to find tasks related to a specific page or subject in my vault. I use an app called Easy Expense to track my mileage and expenses for my business.

```tasks
# Query for any task that includes the words Easy Expense in the description

description includes Easy Expense
```

I hope that you’ve found this helpful. If you’ve got query questions, just comment here and let’s work through them. In the next video/article, we’ll be talking about how to work with the tasks in queries.