Skip to content

Instantly share code, notes, and snippets.

Last active February 16, 2023 20:46
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
A Dataview script for displaying an "On this Day" feature in Obsidian. Read more here:
// update path and minyear if needed
const journalPath = 'Journal/Daily';
const minYear = 2012;
const d = new Date();
const rangeOfYears = (start, end) => Array(end - start + 1) .fill(start).map((year, index) => year + index);
const availableYears = rangeOfYears(minYear, d.getYear() + 1900);
const month = ("0" + (d.getMonth() + 1)).slice(-2);
const day = ("0" + (d.getDate())).slice(-2);
const dateString = month + '-' + day;
availableYears.forEach((y) => {
// you may also have to update this date string, if your files aren't formatted in the default way (YYYY-MM-DD)
var note =`${journalPath}/${dateString}-${y}`);
if (note) {
dv.el('span', `[[${note.file.path}|${y}]] `);
Copy link

devidw commented Feb 16, 2023

When using in the daily note files directly:

To have this in historic files as well and not bound to the current date, we can use:


This will return the current file name, which we can use to extract month + day to then look up differnt years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment