[dataviewjs] snippet - automatically updating links to periodic notes

Hi everybody! Long time lurker, first time poster. I love Obsidian, and have used this forum extensively to help me figure out the Dataview plugin and (more recently) the wide world of dataviewjs! In particular, @Moonbase59 and @mnvwvnm’s answers to others in forum posts have been especially helpful in helping me get oriented.

Okay, so -

Problem: I am tired of manually updating links to the relevant day/week/month/etc. note (using the Periodic Notes plugin for templated creation of all those!), and wanted a solution that would automatically update without me having to manually change the links.

Solution:

var day = moment().format('YYYY-MM-DD_ddd');
var week = moment().format('YYYY-[W]W');
var month = moment().format('YYYY-MM_mmm');
var quarter = moment().format('YYYY-[Q]Q');
var year = moment().format('YYYY');
dv.paragraph("[[" + day + "|📆]] | [[" + week + "|W]] | [[" + month + "|M]] | [[" + quarter + "|Q]] | [[" + year + "|Y]]");

Notes

  • I matched the date formatting to the template in my periodic notes setup so it will link correctly without me having to update it.
  • you can choose to swap out what alias you’d like, if you even want one!
2 Likes