Next calendar week with Templater?

Hey,

I have been looking for a way to add the upcoming calendar week and the current year automatically as a calendar note title.

Let’s say for example we have calender week 34 year 2024. I want the title of the note to be named CW35 2024.

I currently have this: <% tp.file.rename ("Goals " + tp.date.now(“CW YYYY”)) %>

This gives me the current CW. How do I make it to add the next CW instead of the current one?

This could potentially work for local week numbers :blush:

<% tp.file.rename ("Goals " + tp.date.now("[CW]ww gggg", 7)) %>

or this, if you use ISO weeks :

<% tp.file.rename ("Goals " + tp.date.now("[CW]WW GGGG", 7)) %>

In both cases, the 7 within tp.date.now() is an offset of days which is added to the value of now (whenever now is when the template run :blush: ) and then formatted as "[CW]WW GGGG" (following MomentJS format)

Something like this could be an alternative:
(Using a ISO8601 string as the offset)

<% tp.file.rename ("Goals " + tp.date.now("[CW]WW GGGG", "P1W")) %>

Calling moment() directly could be yet another alternative :blush:

You could look at the examples for tp.date.now() in Templater’s doc here: tp.date - Templater

I can’t guarantee this will give you exactly the result you’re expecting though :sweat_smile: … from my side of the screen I’m already in the week 35 so next week for me (without using a reference date) is week 36 :innocent:

It worked. Thank you very much!

1 Like

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