Autofill Next Week

Things I have tried


<%* let ISO_8601_SHORT_FMT = “YYYY-MM-DD”;
let today = moment();
let yesterday = moment(today).subtract(1, ‘d’);
let tomorrow = moment(today).add(1, ‘d’);
let this_week = moment(today).startOf(‘isoWeek’);
let this_week_num = today.isoWeek();
let last_week = moment(today).subtract(1, ‘w’).startOf(‘isoWeek’);
let last_week_num = last_week.isoWeek();
let next_week = moment(today).add(1, ‘w’).startOf(‘isoWeek’);

let next_week_num = next_week.isoWeek();
let week_delta = Math.abs(next_week_num-this_week_num); %>

yesterday: <%yesterday%>
yesterday_str: <%yesterday.format(ISO_8601_SHORT_FMT)%>
today: <%today%>
today_str: <%today.format(ISO_8601_SHORT_FMT)%>
tomorrow: <%tomorrow%>
tomorrow_str: <%tomorrow.format(ISO_8601_SHORT_FMT)%>
last_week: <%last_week.format(ISO_8601_SHORT_FMT)%>
last_week_num: <%last_week_num%>
this_week: <%this_week.format(ISO_8601_SHORT_FMT)%>
this_week_num: <%this_week_num%>
week_delta: <%week_delta%>
next_week: <%next_week.format(ISO_8601_SHORT_FMT)%>
next_week_num: <%next_week_num%>
next_week2: <%next_week2%>

Lesson Plans for the Week of [[<% tp.date.weekday(“YYYY-MM-DD”, 1) %>]]

[[<% tp.date.weekday(“YYYY-MM-DD”, 1) %>]]

  • 01: Reading Lesson
  • 15: Lecture
  • 30: Inquiry Journal
  • 45: Discussion
  • 55: Dismissal

[[<% tp.date.weekday(“YYYY-MM-DD”, 2) %>]]

  • 01: Reading Lesson
  • 15: Lecture
  • 30: Inquiry Journal
  • 45: Discussion
  • 55: Dismissal

[[<% tp.date.weekday(“YYYY-MM-DD”, 3) %>]]

  • 01: Reading Lesson
  • 15: Lecture
  • 30: Inquiry Journal
  • 45: Discussion
  • 55: Dismissal

[[<% tp.date.weekday(“YYYY-MM-DD”, 4) %>]]

  • 01: Reading Lesson
  • 15: Lecture
  • 30: Inquiry Journal
  • 45: Discussion
  • 55: Dismissal

[[<% tp.date.weekday(“YYYY-MM-DD”, 5) %>]]

  • 01: Reading Lesson
  • 15: Lecture
  • 30: Inquiry Journal
  • 45: Discussion
  • 55: Dismissal

What I’m trying to do

I have no idea what I’m doing. I’m just trying to fill out the next week of dates. Should be easy but I’m way past rusty and ChatGPT doesn’t help if you don’t really know what you are doing in Obsidian coding.

I don’t know how to do it in Templater, but Periodic Notes includes date math template tags that make this easy.

You’ve got no idea what you’re trying to do? And you present us with stuff from ChatGPT, which you don’t know what does? How do you expect us to help you then?!

Let’s first of all take a step back, and get a clear idea of what is it you want the template to do? Which output do you want of a working template?

Secondly, do you know how to create templates, and how create notes using those templates? (And are you somewhat familiar with Templater templates, like you’re showing code from?)

Lastly (for now), please include markdown blocks (with our without other code blocks) within four backticks, like in ````, so that we see what’s your markdown attempts, and what’s your ordinary text. (Using four ticks in the forum posts, instead of three, will also allow any other code blocks to look nice in here)

Thank you I can understand that it is frustrating when people don’t know what they are talking about and can’t explain it clearly.

On Friday or the weekend I want to create a template that auto updates the date heading for the next week’s lesson plans.

Lesson plans for Grade 6 [NextMonday]

[NextMonday]

  • Start of period
  • Stuff I do
  • End of Period

[NextTuesday]

  • Start of period
  • Stuff I do
  • End of Period

[NextWednesday]

  • Start of period
  • Stuff I do
  • End of Period

[NextThursday]

  • Start of period
  • Stuff I do
  • End of Period

[NextFriday]

  • Start of period
  • Stuff I do
  • End of Period

Should be pretty easy so I don’t know why I’m pulling out my hair.

So would it be?:

let today = moment();
let next_week = moment(today).add(1, ‘w’).startOf(‘isoWeek’);
let nextmonday = next_week;
let nexttuesday = moment(nextmonday).add(1, ‘d’);
let nextwednesday = moment(nexttuesday).add(1,‘d’);
let nextthursday = moment(nextwednesday).add(1, ‘d’);
let nextfriday = moment(nextthursday).add(1, ‘d’);

I think this should do what I want it to do?

No this doesn’t actually work. I get a parsing error and I don’t know how to troubleshoot that.

<%
let today = moment();
let next_week = moment(today).add(1, ‘w’).startOf(‘isoWeek’);
let nextmonday = next_week;
let nexttuesday = moment(nextmonday).add(1, ‘d’);
let nextwednesday = moment(nexttuesday).add(1,‘d’);
let nextthursday = moment(nextwednesday).add(1, ‘d’);
let nextfriday = moment(nextthursday).add(1, ‘d’);

%>

Next_Monday: <%nextmonday%>
Next_Tuesday: <%nexttuesday%>
Next_Wednesday: <%nextwednesday%>
Next_Thursday: <%nextthursday%>
Next_Friday: <%nextfriday%>

Could you please add four backticks around your code blocks, I’m a bit unsure on what your code actually looks like regarding to quote usage.

And could you also include your error message? It kind of looks OK, if maybe a little convoluted.

I used someone else’s code and finally figured it out.


<%* let ISO_8601_SHORT_FMT = “YYYY-MM-DD”;
let today = moment();
let yesterday = moment(today).subtract(1, ‘d’);
let tomorrow = moment(today).add(1, ‘d’);
let this_week = moment(today).startOf(‘isoWeek’);
let this_week_num = today.isoWeek();
let last_week = moment(today).subtract(1, ‘w’).startOf(‘isoWeek’);
let last_week_num = last_week.isoWeek();
let next_week = moment(today).add(1, ‘w’).startOf(‘isoWeek’);
let next_week_num = next_week.isoWeek();
let week_delta = Math.abs(next_week_num-this_week_num); %>


Lessons plans for [[G6 <%next_week.format(ISO_8601_SHORT_FMT)%>]]

Next_Monday: [[<%next_week.format(ISO_8601_SHORT_FMT)%>]]

Next_Tuesday: [[<%next_week.add(1,‘days’).format(ISO_8601_SHORT_FMT)%>]]

Next_Wednesday: [[<%next_week.add(1,‘days’).format(ISO_8601_SHORT_FMT)%>]]

Next_Thursday: [[<%next_week.add(1,‘days’).format(ISO_8601_SHORT_FMT)%>]]

Next_Friday: [[<%next_week.add(1,‘days’).format(ISO_8601_SHORT_FMT)%>]]

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