Daily Note: Templater Code Doesn't Generate Proper Date-Navigation-Links

What I’m trying to do

Hello fellow wanderers!
Previously in my “Daily Note”-Template I had a simple “date navigation links” templater code which worked fine.
Here:
<%* moment.locale(“de”) -%><[[<% tp.date.now(“YY-MM-DD”, -1, tp.file.title, “YY-MM-DD”) %>]] — [[<% tp.date.now(“YY-MM-DD”, 1, tp.file.title, “YY-MM-DD”) %>]]>

resulting in e.g.:
<[[24-01-09]] — [[24-01-11]]>

Since I am moving partially away from the regular daily note and work more in the weekly, I added the week note link (YY[W]ww) in between. It works, as it generates the template BUT the “tomorrow’s date” is always the date of today:
<%* moment.locale(“de”) -%><[[<% tp.date.now(“YY-MM-DD”, -1, tp.file.title, “YY-MM-DD”) %>]] — [[<% tp.date.now(“YY[W]ww”), tp.file.title, “YY[W]ww”.format(“YY[W]ww”) %>]] — [[<% tp.date.now(“YY-MM-DD”, 1, tp.file.title, “YY-MM-DD”) %>]]>

resulting in e.g.:
<[[24-05-02]] — [[24W18]] — [[24-05-03]]>

where it should be:
<[[24-05-02]] — [[24W18]] — [[24-05-04]]>

I didn’t find any solution in the web or here in the forum regarding this specific issue. Appreciate any help!

Things I have tried

Following you’ll find some trials:

Not working

[[<% tp.date.now("YY[W]ww", 0, tp.file.title, "YY[W]ww") %>]]

[[<% tp.file.title("YY[W]ww").format("YY[W]ww") %>]]

[[<% tp.date.now("YY-MM-DD", tp.file.title, "YY[W]WW") %>]]

“week”/“weekday” - Not Working

[[<% tp.date.week("YY[W]ww"), tp.file.title, "YY[W]ww".format("YY[W]ww") %>]] [[<% tp.date.weekday("YY[W]ww"), tp.file.title, "YY[W]ww".format("YY[W]ww") %>]]

Creates The Right Week-Number “24W10”

[[<% moment(tp.file.title, "YY[W]ww").add(7, "weeks").format("YY[W]ww") %>]]

Produces “Invalid Date”

[[<% moment(tp.date.now("YY-MM-DD"), tp.file.title, "YY[W]ww").add(7, "weeks").format("YY[W]ww") %>]]

Produces the “correct” file, but only works for current week 24W10, following not (24W11)

[[<% tp.date.now("YY[W]ww"), tp.file.title, "YY[W]ww".format("YY[W]ww") %>]]

  • Without “format” not working anymore
    [[<% tp.date.now("YY[W]ww"), tp.file.title( "YY[W]ww") %>]]
  • The “24W11” generated Week Note doesn’t bring any solution

<%* moment.locale(“de”) -%><[[<% tp.date.now(“YY-MM-DD”, -1, tp.file.title, “YY-MM-DD”) %>]] — [[<% tp.date.now(“YY[W]ww”), tp.file.title, “YY[W]ww”.format(“YY[W]ww”) %>]] — [[<% tp.date.now(“YY-MM-DD”, 1, tp.file.title, “YY-MM-DD”) %>]]>

isn’t right. Templater gave me an error. See the bolded part. I’m not sure what you intended.

Thank you for your reply. I am not 100% sure though I understand your question: With the middle part, I want to create the link to the “Weekly Note” in the calendar.

Example of today, not correctly generated with Templater:

After I manually corrected it, it looks like so:

Does this answer your question?

Sorry I took so long to get back to you. Here’s my solution that seems to work on my machine.

<[[<% tp.date.now("YY-MM-DD", -1, tp.file.title, "YY-MM-DD") %>]] — [[<% tp.date.now("YY[W]ww", 0, tp.file.title, "YY-MM-DD") %>]] — [[<% tp.date.now("YY-MM-DD", 1, tp.file.title, "YY-MM-DD") %>]]>

There were two issues with your example that I had to change. First the double quotes you used are “curly quotes” (quotes that curve into the text). They need to be simple double quotes.

Second, the “line in the middle I refer to earlier is” (this is from your example)

 [[<% tp.date.now(“YY[W]ww”), tp.file.title, “YY[W]ww”.format(“YY[W]ww”) %>]]

I don’t believe that this portion is correct and I’m not sure what you intended.

Regardless, the line at the top seems to work and resulted in the following for the day “24-05-04”:

<[[24-05-03]] — [[24W18]] — [[24-05-05]]>
1 Like

Now it took me a little longer…
Thank you so much for your solution. I was comparing your and my code snippets.

Recap:

Basically the mistake was in the “Week Note”-element, where I was using the wrong reference in this section:
tp.file.title, "YY[W]ww".format("YY[W]ww") because this needed to actually reference the file title

PLUS I didn’t need to add the .format("YY[W]ww")

Correct?

Do you know a good resource to learn & improve myself in this? DataView Forum is for non-coder sometimes a bit intimidating.

There are a number of dataview YouTube videos and medium articles. Just search “obsidian dataview”. You are right. The forum is only helpful when you have the basics down. Then it’s a great place to extend your knowledge