What is wrong with my weekly template code?

What I’m trying to do

I am trying to create a weekly template based off the current calendar week, but I can’t seem to get the code correct to signal “current week”. I’d also like to configure the “start of” week and “end of” week.

Things I have tried

[[Journal/Weekly/<%moment(tp.file.title).format(“WW of YYYY”)%>


<%moment(tp.file.title).startOf(‘isoWeek’).format(“WW of YYYY”)%> - <%moment(tp.file.title).endOf(‘isoWeek’).format(“WW of YYYY”)%>

Thanks for the help!

Moment expects the format to only contain the special date characters. So to have any random text like “of” you need to put square brackets around it:

.format("WW [of] YYYY")

You also have smart quotes in your code which won’t work. That might have just been from pasting here though.

Hm, I’ve tried these things and it still does not seem to work. Thanks for the input, though.

What’s the error message?

For the second code I mentioned it presents as
“[[Journal/Weekly/Invalid date - [[Journal/Weekly/Invalid date”

What’s the exact title of your note?

This is my input into my Weekly Note Template…
[[Journal/Weekly/<%moment(tp.file.title).startOf(‘isoWeek’).format(“WW [of] YYYY”)%> - [[Journal/Weekly/<%moment(tp.file.title).endOf(‘isoWeek’).format(“WW [of] YYYY”)%>

Is that what you mean?
I am starting to suspect there may be a glitch in my calendar.

I mean the actual title of the note: tp.file.title

Moment might be having trouble trying to understand it.

The note the code is in is titled “Weekly Note Template”

So if we assume that tp.file.title = Weekly Note Template, Moment will be unable to turn that into a date.

How about:

<% moment().startOf('isoWeek').format("WW [of] YYYY") %>

which will just use the week of the current time?

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