Template for a specific days of the week and days of the month

What I’m trying to do

I use daily notes for planning, tasks, and habits. And I need different templates to be used for different days of the week and month.
For example: If the note is for Sunday, then “Template Sunday” is used, and the other days “Template Day”. And the template for a specific day of the month is “Template 1st day of the month”

I have to make an important remark - Template should not be applied according to the day of creation, but according to which day this daily note belongs to. If I create a note for Monday and today is Sunday, Template Sunday should not be applied to it.

Daily notes format - YYYY-MM-DD

Things I have tried

I am not proficient in programming and so it is very difficult for me to figure out on my own, but I have read and tried to apply information from the following sources:

https://www.reddit.com/r/ObsidianMD/comments/r80fk3/comment/hn33o8j/

https://www.reddit.com/r/ObsidianMD/comments/vtqo4e/different_templates_for_different_weekdays_in/

I’ve been wanting to solve this problem for a long time, and it’s literally taking up all my attention. I would be very happy if you could help me

Hi,

I hope this would be helpful to you, I use a template like this: (Made initilly by some kind soul on this forum, sorry I forgot who and where, and adapted by me:)

<%*
const dayOfWeek = Number(tp.date.now(“d”, 0, tp.file.title, “YYYY.MM.DD”));
const dayOfMonth = Number(tp.date.now(“D”, 0, tp.file.title, “YYYY.MM.DD”));
const month = Number(tp.date.now(“M”, 0, tp.file.title, “YYYY.MM.DD”));
const year = Number(tp.date.now(“YYYY”, 0, tp.file.title, “YYYY.MM.DD”));
const lastDayOfMonth = Number(month === 2 ? ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0 ? 29 : 28) : [4, 6, 9, 11].includes(month) ? 30 : 31);
const doLastDOM = Boolean([1,2,3].includes(dayOfWeek) ? dayOfMonth === lastDayOfMonth : dayOfWeek == 4 ? dayOfMonth >= (lastDayOfMonth - 3) : false);

if (dayOfWeek == 1) {
// Monday
-%>

  • Things for monday :arrow_up_small: :date: <% tp.file.title %>

<%*
}
else if (dayOfWeek == 2) {
// Tuesday
-%>

  • Things to do on tuesday :arrow_up_small: :date: <% tp.file.title %>

<%*
}
else if (dayOfWeek == 3) {
// Wednesday
-%>

  • do stuff :date: <% tp.file.title %>

<%*
}
else if (dayOfWeek == 4) {
// Thursday
-%>

  • do stuff :date: <% tp.file.title %>

<%*

}
else if (dayOfWeek == 5) {
// Friday
-%>

  • Do stuff friday :date: <% tp.file.title %>

<%*
}

// End of Month Tasks
if (dayOfMonth == 01) {
-%>

Anything you want

  • Do stuff and schedule them for the first monday of the current month :date: <% tp.date.weekday(“YYYY-MM-DD”, 8, tp.file.title, “YYYY-MM-DD”) %>

<%*
}
-%>

Good luck!

Edit to add: You will have to add “if” statements for Saturday and Sunday, and for any other date you might need.

Thanks, but I need a specific template to be applied, not just adding some text.
Something like this:
If day of week - Sunday
[[Template Sunday]]

1 Like