Add date functions (yesterday, tomorrow, etc.) to the Template plugin

Please add the ability to get yesterday’s, and tomorrow’s date into/out of the new template plugin. Moment.js has many possibly popular functions for adding or subtracting days/weeks to the current date; these would be useful to me, eg in adding ‘Tomorrow’ and ‘Yesterday’ to my Daily Page template.

35 Likes

+1. Date functions would be incredibly useful.
I often use yesterday/tomorrow/today, but also the week number for example, when associating a daily note to a week and when doing a weekly review.

I agree, some good date-object like functions would be great.

For example, in Vim Mode, if you use ctrl-a or ctrl-x you can increment or deincrement a number. It would be nice to be able to do the same with a date that matches your Daily Notes format. Or do date-math operations based on the current date, or a specified date.

Are you already familiar with the discussions about Expanso, where people are using snippets to create your specific example of a Tomorrow and Yesterday link? Fun with espanso

this would be great

This would be great - I’d like to be able to link my Daily Notes together and be able to go backwards/forwards between them.

@Cheese3.414 This is already possible… Templater can do all of this, using moment.js or vanilla js…

As for navigating between daily notes, Obsidian has native functions for that, you can assign them to hotkeys…

1 Like

+1. I’d love to be able to use the core Templates plugin for this.

Adding yesterday and tomorrow dates to my daily notes is literally the only thing I use Templater for - it seems like overkill to need in for this one thing.

2 Likes

I guess templater took the wind out of improvements to core templates. (I use both).

Are title, date, and time still the only variables available?

They still aren’t :(, I see that there are multiple templating plugins that would solve it, but I think something as common as having:

  • yesterday
  • tomorrow

And for a nicer UX:

  • EOD
  • EOW
  • EOM
  • EOY

adds inmense ammount of value to the default template plugin…

I found my way here multiple times as I was looking for a way to automatically link daily notes from the previous day and next day with a template.

So, Im hoping it will be helpful to drop my current solution here as a stop gap while the Templates plugin still lacks a way to accomplish this.

I was able to use inline dataview queries (obsidian-dataview plugin) combined with existing template variables to create links to the previous day and next day. You will notice that I am using the {{title}} template variable here so that I’m not limited to creating/inserting the template on the same day, but {{date}} works too.

Previous Day

`=link(dateformat(date({{title}})-dur(1d), "yyyy-MM-dd"), "Previous Day")`

Next Day

`=link(dateformat(date({{title}})+dur(1d), "yyyy-MM-dd"),"Next Day")`
1 Like