Finding Old Notes in Obsidian with Dataview

A historical picture of an old map, symbolizing old notes.

The first challenge when it comes to note-taking is writing notes. Note-taking doesn’t work if all you do is collect, you also have to sit down and write.

The second challenge is remembering what you write. If you write often, you’re bound to forget some of it. I know I have numerous articles (and notes) that I look back on and think “did I really write that?”

No AI here my friends: there are many things that I actually did write but don’t remember at all.

But if you use Obsidian, you can do something about that!

Systems for Recall

If you know anything about me, you know that I like to set up systems to optimize my performance. That’s one reason I love Obsidian: it is exceptionally good at systems.

Let’s talk about some different systems we can use to remember what we write.

How to Remember What You Write

A few months ago I wrote about one of the simplest ways that I use to remember what I write. I use randomness to “accidentally” find notes that I once was interested in, but have recently forgotten. If you want to learn how to use randomness in your own vault, see Embrace Serendipity: Discovering Old Notes in Obsidian.

Randomness can be helpful, but there’s a more strategic way to find notes that need reviewing.

We can do this by using dates.

All we have to do is track the last time you edited a particular note. If we set up a system like that, then we can query your notes and resurface notes that we haven’t touched in a while.

So let’s do that!

Setting Up Date Fields for Your Notes

In order to review a note a while after we last updated it, we first need to find a way to add “last modified” dates to our notes.

Fortunately, there are clever people who have built solutions for this, in the form of plugins.

The easiest way I’ve found is to use a plugin called Update time on edit. The Update time on edit plugin does two things: when you create a note, it adds a date “created” field, and when you update a note, it adds (or updates) an “updated” field.

This plugin does have some settings, but for the purposes of this article, I suggest you leave the default settings. All you have to do is install and enable the plugin, and it will start tracking dates for you automatically. Click to open the plugin in your vault.

Once you have the plugin installed and enabled, you might want to go update a few of your notes and make sure its working. If it is working, you should see this data appear in the Properties of any notes that you edit:

An example of created and updated fields in an Obsidian note.

Once you’ve done that, we can move on to the fun part!

Setting Up a Review Dashboard

Once we have our data set up, next we need to query the data. 

Creating a Last Updated view

We’re going to use Dataview to create our dashboards. If you’re new to Dataview, see our introduction to Dataview first. Familiarity with the fundamentals of Dataview will be helpful for you to be able to create and modify your own dashboards.

To start, let’s create a note called “Last Updated” and paste in this code:

```dataview
TABLE dateformat(updated, "yyyy-MM-dd - HH:mm") AS "Last modified"
FROM ""
SORT updated DESC
LIMIT 25
```

This script fetches all of your most recently updated files, and lists them in a table. It doesn’t bother to actually check the date for any file, it just grabs every file that has an “updated” field, sorts them with the newest on top, and limits them to 25.

This is handy for finding a note that you know you edited recently, but can’t quite remember the title. It’s a great view to have on hand, but not quite what we’re looking for.

Tip: the Last Updated view is a handy one to pin to your sidebar. That way you can see a live-updating list of all the files you have modified recently.

Creating a Six Month Review Dashboard

Now that we know what we’re doing (more or less!), we can jump into the deep end.

We already have a query that shows us most recently updated files. All we have to do now is add a date comparison, so we can use the same query to show us six months ago (or six weeks, or six years: whatever we want).

To do that, we have to change our query slightly. Create another note called “Review Old Notes”, and paste in this script:

```dataview
TABLE dateformat(updated, "yyyy-MM-dd - HH:mm") AS "Last modified"
FROM ""
WHERE updated AND updated <= date(today) - dur(6 months) AND updated >= date(today) - dur(6 months 7 days)
SORT updated DESC
LIMIT 25
```

We can modify the script above to show any duration we want. By default I have it set to look back six months, but this may be too far or not far enough for you.

To change the date range, look for the code that says 6 months and 6 months 7 days. The script looks for anything between those days, so you can change that to 3 months or 3 weeks or whatever you like. Just be sure to keep the second date further back than the first, otherwise the script won’t work.

E.g.: If you change the first date to 12 months, then second date has to be further back. So it could be 12 months 1 day, 13 months, 12 months 2 weeks, or anything else as long as it is farther back than the first date.

Reviewing By Date Created

The above script works for notes that you haven’t updated for a while, which is great if we’re trying to refresh our memory of old notes.

But what if we want to see when notes were created?

This too we can do easily, with a small change to the above script. All we have to do is swap out the updated field with the created field.

If you want to try it, create a new note called “Created 6 Months Ago” and paste this code:

```dataview
TABLE dateformat(created, "yyyy-MM-dd - HH:mm") AS "Created"
FROM ""
WHERE created AND created <= date(today) - dur(6 months) AND created >= date(today) - dur(6 months 7 days)
SORT created DESC
LIMIT 25
```

Again, you can edit those durations if you want to. This script will show you notes that you created six months ago.

Styling your Dashboards

By default these dashboards create tables:

A recently created Dashbord in Obsidian

And this works well enough. But personally, I prefer card styling for these sorts of tables.

Cards are a feature of the Minimal theme. If you use Minimal, you can turn the above tables into this:

A recently created dashboard in Obsidian using Cards instead of tables.

To do this, add the cssClasses property to your notes, and add cards as the value, like this:

A screenshot of properties in Obsidian, including file created and modified times.

Conclusion

If you haven’t created your own time-based dashboards in Obsidian, I think you should try it!

It’s a great way to rediscover things that you once cared about. You might be surprised to discover how much you’ve forgotten in six months time, and how much easier it is to remember a note after you’ve reviewed it once or twice.

4 responses to “Finding Old Notes in Obsidian with Dataview”

  1. Instead of adding a plugin to track the last modified date you could use the already present “file.mtime” (see https://blacksmithgu.github.io/obsidian-dataview/annotation/metadata-pages/)

    This is the last modified date according to the file system. In most cases it would be what you expect, but it might depend on what system is used to synchronise the vault

    1. Hi Peter! Thanks for the note. You’re right, file.mtime is a handy feature in Dataview. I use it for some things, but for these kinds of dashboards I didn’t find it accurate enough. Could be my backup system, but the modified time always changed when I didn’t want it to change, and sometimes it didn’t change when I did want it to change. It wasn’t predictable or controllable.

      So I see the above solution as a more universal solution. It takes a little more setup, but works for more people. If mtime works for you though, then feel free to stick with that!

      1. From what I understand of the plugin it actually has the same issue (regarding backup / sync). From the README:

        “This plugin will read the ctime and mtime from obsidian, and thus, the file system. If file change from an external source, the header keys will be updated.”

        I would also prefer it to be opt-in, so only files that already have an “updated” property will be updated – at least as a setting

        I’m gonna see if there’s another plugin that works a little better for my needs – or make one 🙂

        1. You’re correct, it does use those fields on file creation, but it doesn’t update them as frequently as the file system does. It DID still give me some problems on syncing though: I had to quit Obsidian while syncing, and then when I opened it back up everything was correct. Better, but not quite perfect. 🙂

          Since writing this article I have moved on to the “Update frontmatter modified date” plugin, which works even better than the above. It only updates the date when you change the file in Obsidian, which is what I prefer.

          It doesn’t do anything about date created, but you can easily do that with a template.

          I see it also has a setting for “Only update existing fields”… This might be the one for you too!

Leave a Reply

Your email address will not be published. Required fields are marked *