Tasks query, tasks completed in weekly, monthly, quarterly notes

Things I have tried

I have tried searching this forum and have come close to what I am seeking a few times, but not quite. I’ve been struggling on this for a few weeks off and on, and think it’s beyond my skill!

The solutions I have found so far seem to relate to the creation date of the note, so I cannot create weekly notes today for weeks I may have missed in the past.

What I’m trying to do - generally

I’ve been using daily notes to record day to day activities and have been using the Tasks plugin within these notes. At the end of each week, month or quarter I’d like to be able to quickly view a weekly, monthly or quarterly note showing the tasks completed in each period. I intend to add tags to any completed tasks I consider significant so I can compile them into reports easily.

I’d like a query showing the completed tasks in the given period, and a second query showing the same but filtered for my key tasks, e.g. #keydaily

What I’m trying to do - specifics

Therefore I’m trying to summarise tasks completed during each week in my weekly notes. I would like a query to add to a weekly template that will find the completed tasks based on the week of the note, not when the note was created. i.e. if I didn’t create a weekly note last month I should be able to create it today and see the correct results.

Ideally it should be easy to duplicate this query and add filters for my key tasks tags.

I hope that all makes sense.

I’m using Dataview, Tasks and Calendar.
My daily notes have headings formatted as: 2022-09-25 Sun
My weekly notes have the following heading format: 2022-W38

I’d really appreciate any help with this. Thanks in advance!

With the information you give (for now) we can try an example for your weekly note.
For monthly cases and others we don’t have info enough to define “where we have a valid date information - other than the creation date - to compare with the daily notes dates”.
So, for weekly note I’ll take as example the title/name format “2022-W38”.

# weekly

WHERE file.day.weekyear = number(split(this.file.name, "W")[1])
WHERE completed
WHERE contains(tags, "#keydaily")


  • WHERE file.day.weekyear = number(split(this.file.name, "W")[1])
    • file.day it’s an implicit date if the note title has a valid date in it. For the case, 2022-09-25 Sun, it extract the date 2022-09-25.
    • file.day.weekyear - extract the week-of-the-year from the valid date, in case the number 38
    • split(this.file.name, "W")[1]- now I take the file name of the current file (2022-W38) and extract the number after the “W”
    • number(split(this.file.name, "W")[1]) - because the split() results are strings, we need to use the function number() to transform the string “38” in the number 38.
    • WHERE file.day.weekyear = number(split(this.file.name, "W")[1]) - now we define the filter condition: «only files where the number of the week-of-the-year date is equal to the week number we extract from the current weekly note title.
  • WHERE completed - filter only completed tasks
  • contains(tags, "#keydaily") - filter only tasks with the tag #keydaily in the content

Thank you. That works perfectly for my weekly notes. And I really appreciate the explanation.

As you point out I didn’t provide information for my weekly or quarterly notes.
Monthly format: YYYY-MM . Quarterly format is YYYY-[Q]Q (e.g. 2022-Q3).

It would be great if you could explain how to make those work too.

Thanks again - you’ve saved my kids from another day of grumpiness!

For monthly notes in format “yyyy-MM” (ex.: 2022-09)
try something like:

# monthly completed tasks

WHERE dateformat(file.day, "yyyy-MM") = this.file.name
WHERE completed
WHERE contains(tags, "#keydaily")

For Quarterly notes in format “yyyy-[Q]q” (ex.: 2022-Q3) try this:

# Quarterly completed tasks

WHERE dateformat(file.day, "yyyy-'Q'q") = this.file.name
WHERE completed
WHERE contains(tags, "#keydaily")

Thank you. This is perfect!

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