List finished tasks from yesterday's daily note

Things I have tried

# {{title}}

##  Intentions
- [ ] 

## Wins (only finished tasks from yesterday's note)

![[ <% tp.date.now("YYYY-MM-DD", -1) %> #Intentions]]

Also fiddled around with Dataview, but did not get any far.

What I’m trying to do

In my daily notes I keep a list of intentions for today

  • [ ] Learn something new
  • [ ] Be kind to my spouse

I want to list all the wins (the intentions met) of yesterday.

I have no idea:

  • how to list only finished tasks
  • how to list from yesterday’s note only
  • how to get to yesterday’s note based on filename (YYYY-MM-DD) of today’s note
1 Like

Now I’m confused. Dataview or Templater? (because your edit)

Any solution is welcome. I am not bothered by the means, only interested in the goal :slight_smile:

literally yesterday I set up something similar for myself. i used tasks plugin and created a template I insert to each daily note.
this is how my template looks like

## upcoming
```tasks
not done
sort by due
description does not include canceled
due after today```

## todo 
```tasks
not done
description does not include canceled
due before tomorrow```

## backlog
```tasks
not done
description does not include canceled
path includes daily
no due date```

## worklog
```tasks
done after last two days```

# notes

Ok. Let’s try with dataview.

  1. Completed tasks. (for all notes ignore FROM "", if any particular folder - or tag - specify FROM "yourdailynotefolderpath-or-#yourtag)
```dataview
TASK
FROM ""
WHERE completed
```
  1. Tasks completed from yesterday note. If you use the format (YYYY-MM-DD) on file name, you can do something like this:
```dataview
TASK
FROM ""
WHERE completed AND file.day = date(today) - dur(1day)
```

(“file.day” extract date from title)

Try and tell me if works as you wanted

EDIT: well, one problem. In this case dates are relative, not absolute. I.e, today is today and yesterday is yesterday. If you use this query in regular way, when you go back for example for the note a week ago, “yesterday” is the relative to today, not to the date of the daily note. To solve this is necessary other approach.
In this case, if you use templates via Templater to create your daily note, then is possible create a dataview “auto-query” with exact dates.
Query in template:

```dataview
TASK
FROM ""
WHERE completed AND file.day = date(<% tp.date.now() %>) - dur(1day)
```
1 Like

Thanks @mnvwvnm

This works beautiful, but only for today’s note. If I pick any other daily note (for example yesterday’s or tomorrow’s note) it will list all finished tasks of yesterday (absolute), not relative to the daily note.

I tried:

WHERE completed AND file.day = date(<%tp.file.title() %>) - dur(1day) 

but that doesn’t parse.

Thanks @ivarin , I’ll check out your solution a.s.a.p.
I first need to get familiar with Tasks plugin

edit: @mnvwvnm solution is a bit cleaner for my purpose (no need to install Tasks plugin). Thank you for your kind and swift reply though!

WHERE completed AND file.day = date(<% tp.date.now() %>) - dur(1day) works for the moment when you create the daily note. If you try to insert the query in notes already created, then you need another approach!
You want to insert the query in daily notes already created?

1 Like

Yes, if I browse back to any previous date, I’d like to see what the wins of that previous day were.

Also: it happens sometimes that a daily note for a future date is created today. By the time that note is viewed, it should show the wins of the day before.

So I guess the date needs to be derived from the filename (YYYY-MM-DD) - 1 day. Would that be possible at all?

Well, if all your daily notes have the title only with the date in format “2021-10-28”, then I think you can try this (for all the notes):

```dataview
TASK
FROM ""
WHERE completed AND file.day = date(this.file.name) - dur(1day)
```
2 Likes

Thank you so much @mnvwvnm that works perfectly! Thank you so much for your kind help!

It works too with Templater. I think you need to adapt your syntax (I’m not fluent in Templater):

WHERE completed AND file.day = date(<% tp.file.title %>) - dur(1day)

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