Templater calculate the previous week number?

What I’m trying to do

I use Periodic notes to do a weekly review on Sunday, and make a list of objectives for the next week.
So my daily note template has this:

# Objectives this week
![[<% tp.date.now("YYYY")%>-W<% tp.date.now("WW", -1)%>#Objectives for next week]]

But what I’m finding is that the tp.date.now(“WW”) does not seem to support the subtraction I need to calculate the previous week number.

Things I have tried

Any suggestions?

Try using tp.date.now("YYYY-[W]WW", -7) which will give you the year/ week combo 7 days before todays date. Now that I’ve added a W into the mix to differentiate 2024-01 from 2024-W01, since the first is the month of January in 2024, and the latter is the first week of 2024.

Update: Corrected typo from z7 to become -7

Thanks for the suggestion, but it just gives me a templater error:


Console says:

Please check my syntax here, maybe I’m accidentally inserting a typo:

![[<% tp.date.now("YYYY-[W]WW", z7)%>#Objectives for next week]]


That was supposed to be -7, not z7. Sorry for the typo.

Excellent, thanks very much! Works like a charm.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.