# Skipping Weekends in Templater Daily Note Links

**URL:** <https://forum.obsidian.md/t/skipping-weekends-in-templater-daily-note-links/91985>\
**Category:** Workflows & Templates\
**Tags:** templater, internal-links\
**Created:** [November 18, 2024, 8:18pm UTC](https://forum.obsidian.md/t/skipping-weekends-in-templater-daily-note-links/91985 "2024-11-18T20:18:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![calmthesehands](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/c/977dab/32.png) [@calmthesehands](https://forum.obsidian.md/u/calmthesehands)\
**Post date:** [November 18, 2024, 8:18pm UTC](https://forum.obsidian.md/t/skipping-weekends-in-templater-daily-note-links/91985/1 "2024-11-18T20:18:42Z")

</div>

I currently use Daily Notes in a work vault and am using Templater to insert links to yesterday & tomorrow’s daily notes at the top of every daily note to ease navigation. However, since I don’t work on the weekend (Sat/Sun) I was looking for a solution that could skip weekends. I found [this forum post](https://forum.obsidian.md/t/skipping-weekends-with-templater-dates/37910) but thought I’d also share my solution as it’s a touch easier to read!

Note that this is set for a US locale where Sunday = 0 in `tp.date.weekday` – if you’re in a locale where Monday = 0, you’d need to adjust the `tp.date.weekday` numbers to match.

This is my template code for the yesterday link:

```javascript
<%*
const today = tp.date.now("YYYY-MM-DD");
const thisMonday = tp.date.weekday("YYYY-MM-DD", 1);
const lastFriday = tp.date.weekday("YYYY-MM-DD", -2);

let yesterday;
if (today === thisMonday) {
    yesterday = lastFriday;
} else {
    yesterday = tp.date.now("YYYY-MM-DD", -1);
}

tR += `[[${yesterday} – daily]]`;
%>

```

And this is my code for the tomorrow link; since I’m already using the code segment above in my template, I don’t re-declare the `today` variable here. If you’re using the below stand-alone, you’d want to grab that from above.

```javascript
<%*
const thisFriday = tp.date.weekday("YYYY-MM-DD", 5);
const nextMonday = tp.date.weekday("YYYY-MM-DD", 8);

let tomorrow;
if (today === thisFriday) {
    tomorrow = nextMonday;
} else {
    tomorrow = tp.date.now("YYYY-MM-DD", 1);
}

tR += `[[${tomorrow} – daily]]`;
%>

```

---

<div class="post-metadata">

**Author:** ![wambo](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/w/4af34b/32.png) [@wambo](https://forum.obsidian.md/u/wambo)\
**Post date:** [April 7, 2025, 11:27am UTC](https://forum.obsidian.md/t/skipping-weekends-in-templater-daily-note-links/91985/2 "2025-04-07T11:27:33Z")

</div>

A bit late to the party, but I was wondering whether this could be adjusted to not only work with the current day (tp.now(_format_)) but also with any other daily note (with formated title) using tp.date.now(_format_, _source_, _inputformat_) .

I gave it a try. I renamed _today, yesterday and tomorrow_ to _thisday, daybefore, dayafter_ (bc. it will be relative to the notes title date).

Also like OP mentioned, by locale makes the week start with monday on 0, so if you’re looking for those changes you can find them here.  
My files names are also just the date - no `- daily` in there.

The result should be a 6th level Navigation Heading with linking to the (work)day before, that day’s weekly and monthly note, and the following (work)day. It should be easy to remove the weekly and monthly note for you.

###### Monday KW 15 - Navigate

[[2025-04-04| \<\< Previous Day]] | [[2025W15|This Week]] | [[004-April-2025|This Month]] | [[2025-04-08|Next Day \>\>]]

And here the code:

```js
###### <% tp.date.now("dddd", 0, tp.file.title, "YYYY-MM-DD") %> KW <% tp.date.now("WW", 0, tp.file.title, "YYYY-MM-DD") %> - Navigate
[[ <%*
const thisday = tp.date.now("YYYY-MM-DD", 0, tp.file.title, "YYYY-MM-DD");
const thisMonday = tp.date.weekday("YYYY-MM-DD", 0, tp.file.title, "YYYY-MM-DD");
const lastFriday = tp.date.weekday("YYYY-MM-DD", -3, tp.file.title, "YYYY-MM-DD");

let daybefore;
if (thisday === thisMonday) {
    daybefore = lastFriday;
} else {
    daybefore = tp.date.now("YYYY-MM-DD", -1, tp.file.title, "YYYY-MM-DD");
}

tR += `[[${daybefore}| << Previous Day]]`;
%> | [[<% tp.date.now("YYYY",0, tp.file.title, "YYYY-MM-DD")%>W<% tp.date.now("WW",0,tp.file.title,"YYYY-MM-DD")%>|This Week]] | [[<% tp.date.now("00M-" + "MMMM-YYYY") %>|This Month]] | <%*
const thisFriday = tp.date.weekday("YYYY-MM-DD", 4, tp.file.title, "YYYY-MM-DD");
const nextMonday = tp.date.weekday("YYYY-MM-DD", 7, tp.file.title, "YYYY-MM-DD");

let dayafter;
if (thisday === thisFriday) {
    dayafter = nextMonday;
} else {
    dayafter = tp.date.now("YYYY-MM-DD", 1, tp.file.title, "YYYY-MM-DD");
}

tR += `[[${dayafter}|Next Day >>]] `;
%>

```

---

<div class="post-metadata">

**Author:** ![wambo](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/w/4af34b/32.png) [@wambo](https://forum.obsidian.md/u/wambo)\
**Post date:** [April 7, 2025, 12:06pm UTC](https://forum.obsidian.md/t/skipping-weekends-in-templater-daily-note-links/91985/3 "2025-04-07T12:06:12Z")

</div>

Tiny edit (and I only noticed after the post couldn’t be edited anymore:  
In the second line, remove the 2 leading `[[` in front of the first multi line templater code (`<%*`)

---

<div class="post-metadata">

**Author:** ![Colbrac](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/c/94ad74/32.png) [@Colbrac](https://forum.obsidian.md/u/Colbrac)\
**Post date:** [April 6, 2026, 9:22pm UTC](https://forum.obsidian.md/t/skipping-weekends-in-templater-daily-note-links/91985/4 "2026-04-06T21:22:25Z")

</div>

Thanks for this example! It works like a charm after the [[ removal on line 2.

Another oversight I found: for This Week and This Month links, you did not include the tp.file.title reference. I also found that you can use [text] to include text in date formatting strings. So those two links can be corrected and simplified from:

> [[\<% tp.date.now(“YYYY”,0, tp.file.title, “YYYY-MM-DD”)%\>W\<% tp.date.now(“WW”,0,tp.file.title,“YYYY-MM-DD”)%\>|This Week]] | [[\<% tp.date.now(“00M-” + “MMMM-YYYY”) %\>|This Month]]

To:

> [[\<% tp.date.now(“YYYY[W]WW”,0, tp.file.title, “YYYY-MM-DD”)%\>|This Week]] | [[\<% tp.date.now(“00M[-]MMMM-YYYY”, 0, tp.file.title, “YYYY-MM-DD”) %\>|This Month]]

---

<div class="post-metadata">

**Author:** ![Colbrac](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/c/94ad74/32.png) [@Colbrac](https://forum.obsidian.md/u/Colbrac)\
**Post date:** [April 7, 2026, 11:26am UTC](https://forum.obsidian.md/t/skipping-weekends-in-templater-daily-note-links/91985/6 "2026-04-07T11:26:56Z")

</div>

To make the script more readable, I have moved some declarations around and created helper variables. Below is my current definition which does not include the level 6 heading line and automatically places the notes in subfolders under the Journal folder with a separte annual Periodics subfolder for the weekly and monthly notes. NB: I do not work on Fridays, so this version looks at Monday / Thursday.

> \<%\*  
> const filename\_format = “YYYY-MM-DD [wk]WW dd”;  
> const folder\_format = “[Journal]/YYYY/MM/”;
> 
> const thisday = tp.date.now(folder\_format+filename\_format, 0, tp.file.title, filename\_format);
> 
> const thisMonday = tp.date.weekday(folder\_format+filename\_format, 0, tp.file.title, filename\_format);  
> const lastThursday = tp.date.weekday(folder\_format+filename\_format, -4, tp.file.title, filename\_format);  
> const thisThursday = tp.date.weekday(folder\_format+filename\_format, 3, tp.file.title, filename\_format);  
> const nextMonday = tp.date.weekday(folder\_format+filename\_format, 7, tp.file.title, filename\_format);
> 
> let daybefore = tp.date.now(folder\_format+filename\_format, -1, tp.file.title, filename\_format);  
> let dayafter = tp.date.now(folder\_format+filename\_format, 1, tp.file.title, filename\_format);
> 
> if (thisday === thisMonday) {  
> daybefore = lastThursday;  
> }
> 
> if (thisday === thisThursday) {  
> dayafter = nextMonday;  
> }
> 
> const thisWeek = tp.date.now(“[Journal]/YYYY/[Periodics]/YYYY[W]WW”,0, tp.file.title, filename\_format);  
> const thisMonth = tp.date.now(“[Journal]/YYYY/[Periodics]/YYYY-MM”, 0, tp.file.title, filename\_format);
> 
> tR += `[[${daybefore}| << Previous Day]]`;  
> tR += `|`;  
> tR += `[[${thisWeek}|This Week]]`;  
> tR += `|`;  
> tR += `[[${thisMonth}|This Month]]`;  
> tR += `|`;  
> tR += `[[${dayafter}|Next Day >>]] `;  
> %\>
