"On this day" for Daily Notes

I’ve been doing my primary journaling in Day One for years, and one of its best features is “On This Day” where it shows you other entries you created on the same month and date for all the past years you’ve kept a journal. I really wanted to have the same thing in Obsidian, so I added a section to my “Daily Note Template” that embeds a query for the date in question.

The section looks like this, but the embedded query does most of the heavy lifting:

---
## On This Day
```query
file:"{{date:-MM-DD}}"
```

The result is something like this:

I’d really like to use the Daily Notes in Obsidian for my principal journaling, for linking my thinking and whatnot, but I’m very attached to Day One’s book printing service that allows me to print physical volumes of my journals after every year. If anyone knows a convenient way to automate import of Obsidian Daily Notes into Day One, I sure would appreciate it!

16 Likes

that’s a cool idea!

I just added another layer to this:

```query
file:{{date:MM.DD}} -{{date:YYYY}}
```

(specifically the -{{date:YYYY}})

This will remove the current year’s note (in other words, the note you’re currently in).

Side note: @ianlhayes How did you get the code block to work inside the code block here on the forum? Mine keeps terminating on the first set of tick marks.

Thank you, this tidies up my dailies tremendously! As far as getting a code block into a code block, I think trial and error was how I handled it.

Looks like four presses of the spacebar works to declare a code block on the forum. For tidiness, I did four spaces at the beginning of each line.

Spaces… Dammit. I even knew that. Thanks.

Great idea by the way.

should add “()” in query :

eg:
file:({{date:MM.DD}} -{{date:YYYY}})

Thanks.

FWIW I use dataview now for this. Anyone who is interested:

### On This Day
```dataview
table file.mtime as LastEdit
from ""
where contains(file.name, "05.07") and !contains(file.name, "2021")
```
1 Like

Thank you for this! I’m still trying to wrap my head around the different plugins I need to enable in order to have the dates automatically entered. What methods are you using to pull the current date, etc. into dataview?

1 Like

Okay, it turns out I have a problem. My search query doesn’t find other entries from the same day that I have imported in the past, e.g. I have multiple entries from 2019-05-24 that are listed as 2019-05-24a, 2019-05-24b, etc. Is there a way I can word my query to capture possible suffixes as well? Right now my query only finds the numeric entries and so my embedded query only shows one entry per day.

1 Like

Hey, I used to use Day One so I understand what you’re saying. I’ve found a way to simulate it’s metadata. Here’s an example of it:

I use Templater in order to create the dates for the Time of Creation, and it’s Last Modification. These are the lines for the On this day Info Admonition and for the lines of dataviewjs needed to scan all journal entries starting from 2022 (when I started using Obsidian) and ending in 2122 (99 years from now) to find journal entries which it’s title month and day matches with that of the current journal entry’s title’s month and day.

I have decided to use the Title because, occasionally, the Creation Date is not the same as the File’s Title which is also a Date.

Here are the lines of Dataviewjs and Info Admonition:

title: On this day:


```dataviewjs
// set your own minimum year and the path to your journals (if applicable)
const minYear = 2022;
const maxYear = 2122;
const journalPath = 'Calendar/Journals';

const rangeOfYears = (start, end) => Array(end - start + 1)
  .fill(start)
  .map((year, index) => year + index)
const d = new Date(dv.date(dv.current().file.name));
const currentYear = d.getFullYear();
const availableYears = rangeOfYears(minYear, maxYear);
const month = ("0" + (d.getMonth() + 1)).slice(-2);
const day = ("0" + (d.getDate())).slice(-2);
const dateString = month + '-' + day;

availableYears.forEach((y) => {
	var note = dv.page(`${journalPath}/${y}-${dateString}`);
	if (note && y !== currentYear) {
		dv.el('div', `[[${note.file.path}|${y}]]`);
	}
});

By the way, you have to Enable JavaScript Queries in Dataview settings.