-
-
Save dannberg/48ea2ba3fc0abdf3f219c6ad8bc78eb6 to your computer and use it in GitHub Desktop.
--- | |
created: <% tp.file.creation_date() %> | |
--- | |
tags:: [[+Daily Notes]] | |
# <% moment(tp.file.title,'YYYY-MM-DD').format("dddd, MMMM DD, YYYY") %> | |
<< [[Timestamps/<% tp.date.now("YYYY", -1) %>/<% tp.date.now("MM-MMMM", -1) %>/<% tp.date.now("YYYY-MM-DD-dddd", -1) %>|Yesterday]] | [[Timestamps/<% tp.date.now("YYYY", 1) %>/<% tp.date.now("MM-MMMM", 1) %>/<% tp.date.now("YYYY-MM-DD-dddd", 1) %>|Tomorrow]] >> | |
--- | |
### 📅 Daily Questions | |
##### 🌜 Last night, after work, I... | |
- | |
##### 🙌 One thing I'm excited about right now is... | |
- | |
##### 🚀 One+ thing I plan to accomplish today is... | |
- [ ] | |
##### 👎 One thing I'm struggling with today is... | |
- | |
--- | |
# 📝 Notes | |
- <% tp.file.cursor() %> | |
--- | |
### Notes created today | |
```dataview | |
List FROM "" WHERE file.cday = date("<%tp.date.now("YYYY-MM-DD")%>") SORT file.ctime asc | |
``` | |
### Notes last touched today | |
```dataview | |
List FROM "" WHERE file.mday = date("<%tp.date.now("YYYY-MM-DD")%>") SORT file.mtime asc | |
``` |
@Robiton @Gryn23 I'm having the same problem at @Gryn23.
I updated the "tomorrow" link Templater code to [[Timestamps/<% fileDate = moment(tp.file.title, 'YYYY-MM-DD-dddd').add(1, 'd').format('YYYY-MM-DD-dddd') %>|Tomorrow]]
. Then, I modified Templater settings so that all new files created in the Timestamps
directory would have the Daily Note template applied automatically.
It works great when clicking that link to create a new note.
However, if a note currently exists (such as the Yesterday link), it does not recognize the note. Because the Timestamps/
in the [[]] link helps for creating a new note, but isn't necessary when linking to an existing note.
@Robiton if you have a solution for this, let me know. I was in the process of updating the original post but couldn't get it working myself.
Nice!
Strange that leap day gave a problem with you, it didn't give problems with me.
This is my slightly altered version of your script, but I don't think there are big differences. Main difference is that I use it for daily to do lists, and I wanted the notes as a possibility, but out of the way to keep distractions at bay. Hence the many <br>
lines. Also the date format is changed to Dutch order:
`tags: #task #todo
<% moment(tp.file.title, 'YYYY-MM-DD').format("dddd, DD MMMM, YYYY") %>
<< [[<% fileDate = moment(tp.file.title, 'YYYY-MM-DD-dddd').subtract(1, 'd').format('[To_do]/YYYY/MM-MMMM/YYYY-MM-DD-dddd') %>|Yesterday]] | [[<% fileDate = moment(tp.file.title, 'YYYY-MM-DD-dddd').add(1, 'd').format('[To_do]/YYYY/MM-MMMM/YYYY-MM-DD-dddd') %>|Tomorrow]] >>
---
#### To Do
- [ ]
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
---
#### Notes
---
#### Notes created today
List FROM "" WHERE file.cday = date("<%tp.date.now("YYYY-MM-DD")%>") SORT file.ctime asc
#### Notes last touched today
List FROM "" WHERE file.mday = date("<%tp.date.now("YYYY-MM-DD")%>") SORT file.mtime asc
@Robiton @Gryn23 Scratch that. I got it working. It doesn't really handle leap day correctly (of course I'm playing with it on 2/29 lol) but it should work every other day. I've updated the gist with the working code.
Sadly, updated code still creates a -1 if there is already a note for that day.
Anyone have any other ideas?
Hm, I'm at a loss.
The challenge is that the Daily Note template uses today (file.cday
) as a base for all the Templater code. Which means if you click on "Tomorrow" in today's daily note to create tomorrow's note, then Tomorrow's note will have broken yesterday/tomorrow links as well as the two dataview tables.
I don't believe there's a way to pass through information through a link. Meaning, if you click on Tomorrow, you can tell the new note that you actually want file.cdate + 1
for all the Templater code.
Maybe there's a way to store the date we want as a variable in the note? Although I'm totally blanking on how to actually execute this.
@Robiton @dannberg I have no idea why it's not working with you guys, it is with me. If the note already exists, the tomorrow link will just open that file in my vault. Here's my latetst code. The code I posted before was already working, but since then I installed:
- Update time on edit
- Calender
- Periodic notes
explanation:
- plugin 1 makes sure that the date created and date modified are written into the properties of the file, and not overwritten when you migrate to a new computer, or sync to another device.
- plugin 2 speaks for itself. It will ask you if you want to migrate daily notes to it: do so.
- plugin 3 allows me to make a weekly note as well. You need to enter the settings and point the plugin to where your daily notes folder and your week folder lives, and where the templates for the two live.
- After that you need to do that again in Templater (!)
This is the most important code of my daily note template:
`##### <% moment(tp.file.title, 'YYYY-MM-DD-DDDD').format("dddd, DD MMMM YYYY") %>
<< [[<% fileDate = moment(tp.file.title, 'YYYY-MM-DD-dddd').subtract(1, 'd').format('[To_do/Dag]/YYYY/MM-MMMM/YYYY-MM-DD-dddd') %>|Yesterday]] | [[<% fileDate = moment(tp.file.title, 'YYYY-MM-DD-dddd').add(1, 'd').format('[To_do/Dag]/YYYY/MM-MMMM/YYYY-MM-DD-dddd') %>|Tomorrow]] >>`
This is the template for my weekly note. Of course you need to change the names of the folder, and translate "Volgende week" with 'next week'.
`##### <% moment(tp.file.title, 'YYYY-[W]-WW').format("[Week] ww - DD MMMM YYYY") %>
<< [[<% fileDate = moment(tp.file.title, 'YYYY-[W]-WW').subtract(1, 'w').format('[To_do/Week]/YYYY/MM-MMMM/YYYY-[W]-WW') %>|Vorige week]] | [[<% fileDate = moment(tp.file.title, 'YYYY-[W]-WW').add(1, 'w').format('[To_do/Week]/YYYY/MM-MMMM/YYYY-[W]-WW') %>|Volgende week]] >>`
My properties are in the template too. I've hidden properties after I made sure they work. Unhidden this is what shows in the template:
And this is what's spit out if I make a weekly note, (but only if you do so in the right folder! Select the right folder, click right and choose new note, or click "volgende week" on an existing note. Making weeknumbers visible in Calender and clicking an empty weeknumber (or day) works as well.) As you see the "Update time on edit" plugin automatically added date properties.
@pantsmasterson you need to get rid of the quotation mark (') before and after the code. Or maybe you didn't install the templater plugin?
I put the ticks in the comment so they'd appear as code in the Github comment -- they don't appear in the template itself. In the template, it is exactly as it appears in the screenshot, and renders as that piece of code rather than the cursor at that position (which I assume is what's supposed to happen). In the templater code, I've cut and pasted exactly what appears above. The Templater plugin is installed and active.
- Did you tick "automatic jump to cursor" in Templator's options?
- And maybe a stupid question, but you pasted '<% tp.file.cursor() %>' in your template, right? It's supposed to stay code in your template, and only when you 'create new note form template' it should give you a note without the code and just the cursor below your Notes heading.
Aha! It was automatic jump to cursor! Thank you so much -- I'd never have puzzled that through solo.
Haha, glad to help, I'm a beginner myself.
You're not the first person with a question about <% tp.file.cursor() %>
. I should be explicit about this being a setting that needs to be enabled in the post. Will update!
First of all, thanks to @dannberg for laying all this out in your blog post! I've followed along to create my own dailynote setup.
For some reason, your "notes created today" and "notes last touched" dataview snippets wouldn't render at all once the daily note got created, so I did some googling and found this. I've modified the dataview snippet like below and now it's rendering perfectly!
For anyone who's having issues, try out this code instead!
List FROM "" WHERE file.cday = date("<% tp.date.now() %>") SORT file.ctime asc
List FROM "" WHERE file.mday = date("<% tp.date.now() %>") SORT file.mtime asc
How to set automatic directory of new daily note, i can set in settings that new daily note will appear in 2024/06 june/"note", but when new month starts, i need to set it again to 2024/07 july/"note" manually.
@MochyPei Enter this in the Date format field:
YYYY/MM MMMM/YYYY-MM-DD-dddd
If you're running Obsidian on ChromeOS via Linux virtual machine, you need you replace <% tp.file.creation_date() %>
with <% tp.file.last_modified_date("YYYY-MM-DD hh:mm") %>
or you'll consistently get 1970-01-01 01:00
I am getting the Parsing error shown below circled in RED after copying the RAW code from the Github page and pasting it into my Daily Note template file located in Extra/Journal/Template, Daily Note file. Can anybody in this forum please clarify to me why this error is being generated? It says "Expected one of the following:" but I do not know what it is referring to. I am using the latest Obsidian/Templater on a Windows 10 PC. Any advice welcome.
### Notes created today
Dataview: Error:
-- PARSING FAILED --------------------------------------------------
> 1 | List FROM "" WHERE file.cday = date("<%tp.date.now("YYYY-MM-DD")%>") SORT file.ctime asc
| ^
Expected one of the following:
'(', ')', '*' or '/' or '%', '+' or '-', ',', '.', '>=' or '<=' or '!=' or '=' or '>' or '<', '[', 'and' or 'or'
### Notes last touched today
Dataview: Error:
-- PARSING FAILED --------------------------------------------------
> 1 | List FROM "" WHERE file.mday = date("<%tp.date.now("YYYY-MM-DD")%>") SORT file.mtime asc
| ^
Expected one of the following:
'(', ')', '*' or '/' or '%', '+' or '-', ',', '.', '>=' or '<=' or '!=' or '=' or '>' or '<', '[', 'and' or 'or'
@1artist use these instead :
List FROM "" WHERE file.cday = date("<%tp.date.now('YYYY-MM-DD')%>") SORT file.ctime asc
List FROM "" WHERE file.mday = date("<%tp.date.now('YYYY-MM-DD')%>") SORT file.mtime asc
Hrm, how does the code I have compare to yours?