How can I display the current date and the date X number of days before it

What I’m trying to do

Trying to add a section to a template where it displays the current date and I want to display the date 5 days ago to make a “Week of: first date to current date”. This is to create a weekly review document every Friday that on creation, assigns the proper work week

In the end the template should function like this:
Week of: {{date - 5days}} to {{date}}

Things I have tried

Ive tried using this format although it does not accomplish the above functionality
Current Date: {{date:YYYY-MM-DD}}
Date 5 days before: {{date:YYYY-MM-DD -5d}}

I use regularly the Templater plugin for this kind of thing. Not sure if this can be done without community plugins.

<% tp.date.now(“YYYY-MM-DD”) %> will output today’s date as YYYY-MM-DD

<% tp.date.now(“YYYY-MM-DD”).add(-1, ‘days’).format(“YYYY-MM-DD”) %> will output yesterday’s date as YYYY-MM-DD

You can use Templater functions to return the date of the first day of the week (I think this is what you want), but I can’t remember how to format it.

It can’t. The suggestion of Templater is good.

The Periodic Notes plugin can do it too, and its syntax is easier to read, but of course it only works in daily/weekly/etc. notes.

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