Traversing Weekly Notes in Obsidian with Templater

Result

<< [[2022-W30]] | [[2022-W32]] >>

Implementation

If you create Weekly Notes on Sunday, the template should have the following structure:

<< [[<% tp.date.now("YYYY") %>-W<% tp.date.now("WW") - -1%>]] | [[<% tp.date.now("YYYY") %>-W<% tp.date.now("WW") - -3 %>]] >>

If you create Weekly Notes on Monday, the template should have the following structure:

<< [[<% tp.date.now("YYYY") %>-W<% tp.date.now("WW") %>]] | [[<% tp.date.now("YYYY") %>-W<% tp.date.now("WW") - -2 %>]] >>

Why?

As far as I can tell, tp.date.now("WW") changes on Monday. Posts like this seem to imply that moment.js (the library that powers tp.date) also thinks weeks start on Sunday and end Saturday, but in my own testing with .now() that does not seem to be the case.

Sunday -> tp.date.now("WW") = 29

Tuesday (i forgot to run this on Monday, sue me) -> tp.date.now("WW") = 30

In addition, templater ignores "+" meaning you have to subtract negative numbers to get the desired result, which explains the "- -1" and "- -3" above.

Summary

Read These Next

I Wish Programming Were More Emotional

I wish others could feel the way programming pulls on my heartstrings

I love copy and paste

Never do the same work more than once

The Carbon Cycle and Content Creation

Highlight clipped from stream: TRUE OBSIDIANERS ONLY; THE SETUP (META)

Stay in Touch

Each week, I send out something that looks like this. Sign up below if you want in!