How to show tasks completed during certain time?

I have a system of cascading periodic notes (Daily ==> Weekly ==>Monthly etc.). And I have bunch of tasks. While I’m still choosing between having one file per task and having “inline tasks” in notes, I’m currently favouring the latter approach. So the tasks would be something like

I would then have a Dataview-query in the relevant project-file as well as the daily note of the DoDate, showing any related tasks. For example, the one in daily note looks like this:

TASK
FROM ""
WHERE DoDate = this.file.day

And it works fine.

Now, I would like to have a weekly note that showed all tasks I completed during the week. How could I do that? It needs to be a fixed week, from Monday to Sunday, so dynamic range (closed in the last 7 days) doesn’t work. I have a link from and to the daily note to the weekly note, so could I somehow refer to the dv-queries in the daily notes? Or, as the filenames of the daily notes are basically dates, use them as date-values?

The way I refer to the days in the weekly note is like this:

Days:: [[{{monday:YYYY-MM-DD}}]], [[{{tuesday:YYYY-MM-DD}}]],etc.

could those be used for the query, or is there another approach? As I basically need a list of tasks that were closed on those dates.

1 Like

Hi, again.

To start this discussion, please complete your task example. (To see how you format your DoDate in task - inline?)

One issue is the way how you define date for tasks; another one is the “core” date to compare with tasks date, i.e., if your weekly note have a field (title, creation date, other field…) with a fixed date to use as universal solution to all your queries in weekly notes.

1 Like

Ah yes, we meet again :slight_smile: . It seems I forgot to actually post what my tasks look like. They look something like this:

- [ ] this is a task [Project:: [[Project_A]]], [DoDate:: 2021-12-24]

Not all tasks would be a part of the project so that part is optional. Daily notes then have the query I posted in the original message and it works. It shows all tasks with DoDate for that day.

To try a solution without any special way to input date in each weekly note (i.e., to works in all your weekly notes without manually input any date), two more questions:

  1. What’s the title format of your weekly note?
  2. If the title doesn’t have the yyyy-mm-dd included, it’s reliable work with the creation date of your weekly note?
    The day is not important. From creation date I just want to know if the week is the same (for example, it’s not important if you create weekly note in wednesday or sunday… but if you created it between monday and sunday of the week in question).
  1. The format of my weekly notes is [[gggg-[W]ww]], for example this week is [[2021-W51]]. This is the default format of the Periodic Notes-plugin which I use to create my notes.
  2. I think the most common creation-date for weekly notes is the preceding Sunday of the week. That is, as one week comes to its end, I do the weekly review, and then create the new note for the next week.

Well, from your weekly title format I don’t know how to obtain a valid week date (even if that is possible).

But working with the file creation date…

```dataview
TASK
WHERE !completed AND DoDate.weekyear = (this.file.cday - dur(1days)).weekyear AND DoDate.year = this.file.cday.year
```

Explaining:

  • !completed (for incompleted tasks), or completed (only for completed taks), or nothing (all tasks);
  • <date>.weekyear gives the number of the week in the year (e.g. the “51” as in your “W51” in title); <date>.year gives you the year;
  • DoDate.weekyear = (this.file.cday - dur(1days)).weekyear
    As you said that usually your weekly note is created in sunday, I just give an interval of one day (you can add more) to the possibility of the date creation be one day later (Monday, a day in the next week). - dur(1days) is to define a date 1 day before the creation date.
    If you’re sure your creation date is in the same week of the wanted tasks, then you can use only this.file.cday.weekyear.
  • But we have the same “week numbers” all years. Then we need to add the condition extra of equivalent year: DoDate.year = this.file.cday.year (i.e. “the year of the tasks need to be the same year of the creation date”);
  • this last point is a warning: this query has a problem with the last/first week of the year > January 1 is a new week and a new year. In this particular case you need to define manually the dates for you weekly note.
1 Like

I’m trying to follow the instructions… When I create the weekly note on Sunday, I create it for the next week. So Sunday this week (Week51) I would review Week51 and then create the note for Week52. So I think I need = (this.file.cday + dur(1days))? And I would be listing completed tasks, so I will use “completed” and not “!completed”.

I don’t think I have seen “weekyear” mentioned in the documentation? I feel like there’s so much to learn and I can barely keep up…

Anyway, I made the changes to show completed tasks and reflect that I make the weekly note on Sunday before the week, and it seems to be working :)! I need to thank you again for helping me, you are a machine!

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