--- | |
created: <% tp.file.creation_date() %> | |
--- | |
tags:: [[+Daily Notes]] | |
# <% moment(tp.file.title,'YYYY-MM-DD').format("dddd, MMMM DD, YYYY") %> | |
<< [[<% fileDate = moment(tp.file.title, 'YYYY-MM-DD-dddd').subtract(1, 'd').format('YYYY-MM-DD-dddd') %>|Yesterday]] | [[<% fileDate = moment(tp.file.title, 'YYYY-MM-DD-dddd').add(1, 'd').format('YYYY-MM-DD-dddd') %>|Tomorrow]] >> | |
--- | |
### 📅 Daily Questions | |
##### 🌜 Last night, after work, I... | |
- | |
##### 🙌 One thing I've 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 | |
``` |
Not a real coder here - I've got
- the templates enabled
- the settings switched on I believe
- and a new empty daily note in the templates folder as the instructions say
but where exactly do I paste the raw template code here?
I'm guessing I just paste it into the empty template note in source mode, but for me
<% moment(tp.file.title,'YYYY-MM-DD').format("dddd, MMMM DD, YYYY") %>
still shows up coded rather than the date
and I get this in the bottom sections
Notes created today
Dataview: Error:
-- PARSING FAILED --------------------------------------------------
1 | List FROM "" WHERE file.cday = date("<%tp.date.now('YYYY-MM-DD")%>") SORT file.ctime asc
| ^
2 |
Expected one of the following:
'(', 'null', boolean, date, duration, file link, list ('[1, 2, 3]'), negated field, number, object ('{ a: 1, b: 2 }'), string, variable
Dataview: Error:
-- PARSING FAILED --------------------------------------------------
1 | list from "" where file.cday = date("<% moment(tp.file.title,"YYYY.MM.DD").format("YYYY-MM-DD") %>") sort file.ctime asc
| ^
2 |
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
| ^
2 |
Expected one of the following:
'(', 'null', boolean, date, duration, file link, list ('[1, 2, 3]'), negated field, number, object ('{ a: 1, b: 2 }'), string, variable
I also had same problems as @chump 's.
Dataview: Error:
-- PARSING FAILED --------------------------------------------------
1 |
> 2 | List FROM "" WHERE file.cday = date("<% tp.date.now("YYYY-MM-DD") %>") SORT file.ctime asc
| ^
3 |
Expected one of the following:
'(', ')', '*' or '/' or '%', '+' or '-', ',', '.', '>=' or '<=' or '!=' or '=' or '>' or '<', '[', 'and' or 'or'
I figured out the issue with dataview - when i was pasting the code, for some reason it was creating some extra spaces. However @dannberg I'm still for some reason having issues with this part of the code
# <% moment(tp.file.title,'YYYY-MM-DD').format("dddd, MMMM DD, YYYY") %>
It's not just yours though, other templates where moment used weren't working for me, although the yesterday/tomorrow part works oddly.
This is the first time I am playing with this, but I think if you add a "+" after the % like this:
# <%+ moment(tp.file.title,'YYYY-MM-DD').format("dddd, MMMM DD, YYYY") %>
Wow!! That did it. I'm confused as to why that works? I don't see the + in anyone's sample codes. major thanks for solving that one for me @Claustn I've been racking my brain for days on it.
That's so strange. I have no idea what the +
does there, but I'm glad you got it working!
If anyone reading this knows why some people need a +
and others don't, let me know and I can update the post.
From the documentation of templater https://github.com/SilentVoid13/Templater/blob/master/docs/src/commands/dynamic-command.md
I was missing the tasks that I've not completed from other days and modified the template a bit! If you think it'd be useful...
##### 🚀 Thing(s) from other days that I need to finish
```
dataviewjs
dv.taskList(dv.pages('"Timestamps"').file.tasks.where(t => !t.completed && t.text != ""));
```
Just noticing that the section for "Notes created today" uses the current date, so if you create a note for a day in the future or past, it won't give the correct info. I sometimes create future or past notes for upcoming info or if I missed a day. Is there an easy way to update this?
I am just staring out with Obsidian and came across this great template. However, I also followed the suggestion of storing daily notes in "Timestamps/Year/Month/Day", in which case the Yesterday and Tomorrow buttons don't quite work (they create a file in the root directory and without the template. I solved it by updating the code for the tomorrow button as follows:
fileDate = moment(tp.file.title, 'YYYY-MM-DD-dddd').add(1, 'd').format("[Timestamps]/YYYY/MM-MMMM/YYYY-MM-DD-dddd")
and similarly for the yesterday button. Then in the Templater settings, under "Folder Templates", I added the "Timestamps" folder with the daily note template (wherever it is stored for you). Now, when creating new notes with the yesterday and tomorrow buttons, it seems to work, hopefully this will help someone with the same problem.
I will now look for easy ways to create a note for an arbitrary day but at worst you can just create a new note with the date in the title.
@szhydkov thanks! I had the same issue and that solved it perfectly!
I am just staring out with Obsidian and came across this great template. However, I also followed the suggestion of storing daily notes in "Templates/Year/Month/Day", in which case the Yesterday and Tomorrow buttons don't quite work (they create a file in the root directory and without the template. I solved it by updating the code for the tomorrow button as follows:
fileDate = moment(tp.file.title, 'YYYY-MM-DD-dddd').add(1, 'd').format("[Timestamps]/YYYY/MM-MMMM/YYYY-MM-DD-dddd")
and similarly for the yesterday button. Then in the Templater settings, under "Folder Templates", I added the "Timestamps" folder with the daily note template (wherever it is stored for you). Now, when creating new notes with the yesterday and tomorrow buttons, it seems to work, hopefully this will help someone with the same problem.
I will now look for easy ways to create a note for an arbitrary day but at worst you can just create a new note with the date in the title.
I had the same problem with yesterday and tomorrow dates that don't yet exist and this solved it, thanks so much!
For folks who have a daily note with a non date name, or in a non US format, rather then using:
# <% moment(tp.file.title,'YYYY-MM-DD').format("dddd, MMMM DD, YYYY") %>
Which uses the file title for date formatting you can use:
moment(tp.file.creation_date(),'YYYY-MM-DD').format("dddd, MMMM DD, YYYY") %>
This allows you to name your Daily Notes in anyway you see fit (In my case I use a different date format with some extra characters), instead it takes the date the file created instead.
Which means now my daily notes are not from # Wednesday, January 20, 2021
😆
and similarly for the yesterday button. Then in the Templater settings, under "Folder Templates", I added the "Timestamps" folder with the daily note template (wherever it is stored for you). Now, when creating new notes with the yesterday and tomorrow buttons, it seems to work, hopefully this will help someone with the same problem.
This is what worked for me. I had been storing my Daily Notes in the "Daily Notes" folder and didn't realize that the [Timestamps] part of the code actually meant the Timestamps folder. Now it works and I think this is a much better daily note template than what I was using before.
Thank you and good job OP and everyone else who helped, this was a real team effort lol
tags:: [[+Daily Notes]]
I noticed all your templates have tags set with tags::
instead of tags:
and I've searched through the Obsidian reference material could not understand why you add that extra colon when it's not part of the syntax. Any chance you could explain what's going on here?
@djchateau ha, great eyes. The short answer is that the extra colon does absolutely nothing. You can ignore.
The longer answer is that this is a holdover from when I was using Roam Research. On that platform, using two colons to denote tags gave it specific functionality. I never really fully wrapped my head around Roam Research, or using block-based note-taking to the fullest, but the double colon is a habit that came over with me when I moved to Obsidian. It has NO functionality in Obsidian, so I never really spent time to 1) break the muscle memory or 2) had motivation to find & replace in all my imported notes. Therefore, tags::
is just located everywhere in my Obsidian system, in both old notes and new.
@jiwonsim @chump I see a "parsing failed" error when viewing the Daily Note Template post itself. When you create a new note using that template, with the Templater plugin working correctly, it should parse the code correctly in the new note that was created from the template.
Hi. This parsing error appears because of the double quotes inside outer double quotes. Maybe it will be understandable directly in my fix:
Just change the double quotes to single quotes:
### 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
It works fine for me when I employ the template
Thanks for your blog post. It really made my day better.
THanks to the author for grat work, I have a question, how could I make sure new notes are created wthin timestamps folder using the same structure as creating new daily note, when creating tommorows or yeserday's note by below function? Right now it creates new files in main folder.
<< [[<% fileDate = moment(tp.file.title, 'YYYY-MM-DD-dddd').subtract(1, 'd').format('YYYY-MM-DD-dddd') %>|Yesterday]] | [[<% fileDate = moment(tp.file.title, 'YYYY-MM-DD-dddd').add(1, 'd').format('YYYY-MM-DD-dddd') %>|Tomorrow]] >>
THanks to the author for grat work, I have a question, how could I make sure new notes are created wthin timestamps folder using the same structure as creating new daily note, when creating tommorows or yeserday's note by below function? Right now it creates new files in main folder.
<< [[<% fileDate = moment(tp.file.title, 'YYYY-MM-DD-dddd').subtract(1, 'd').format('YYYY-MM-DD-dddd') %>|Yesterday]] | [[<% fileDate = moment(tp.file.title, 'YYYY-MM-DD-dddd').add(1, 'd').format('YYYY-MM-DD-dddd') %>|Tomorrow]] >>
See my comment above: https://gist.github.com/dannberg/48ea2ba3fc0abdf3f219c6ad8bc78eb6?permalink_comment_id=4438780#gistcomment-4438780
I wanted to share my solution to this. I am not the most consequent daily note taking guy out there and thus there may be days where I don't take notes. The provided solution doesn't work for me as it only looks at the day before and after.
With some help of the Dataview plugin we can retrieve the "latest previous" and "earliest next" notes. In the frontmatter block I additionally have the date and a tag daily-note
. In the template the frontmatter block looks like this:
---
tag: daily-note
date: {{date}}
---
And this is the code that I use for the previous/next daily note navigation:
```dataviewjs
const DAILY_NOTES = dv.pages('"<path to daily notes directory>" and #daily-note');
const TODAY_DATE = dv.current().date;
const PREV_NOTE = DAILY_NOTES
.where(note => note.date < TODAY_DATE)
.sort(note => note.date, 'desc')
.limit(1)[0];
const NEXT_NOTE = DAILY_NOTES
.where(note => note.date > TODAY_DATE)
.sort(note => note.date, 'asc')
.limit(1)[0];
const PREV = PREV_NOTE ? `[[${PREV_NOTE.file.name}|Previous]]` : 'None';
const NEXT = NEXT_NOTE ? `[[${NEXT_NOTE.file.name}|Next]]` : 'None';
dv.paragraph(`<< ${PREV} | ${NEXT} >>`);
```
For the "previous/next" issue, I came across this similar blog post about someone else's Obsidian daily notes template which links to this DataviewJS snippet which seems pretty airtight FWIW.
Thanks all. I've added a link to that blog post in the original post.
i love you @dannberg thank you for being the gateway drug to a new micro obsessive productivity increasing tool
@nnnolan happy to be an enabler
I got this for the date
# <%+ moment(tp.file.title,'YYYY-MM-DD').format("dddd, MMMM DD, YYYY") %>
But when i'm getting "Invalid Date" : (
I suspect this is because you are trying to look at your Template-version of the file in readview, but it'll only work when used in an execution of a new file made using the template.
For anyone not using the Templater plugin for anything else than getting the date, i found that you can just rely on the core plugin to get the current date with {{date}}. i.e:
List FROM "" WHERE file.cday = date({{date}}) SORT file.ctime asc
and
List FROM "" WHERE file.mday = date({{date}}) SORT file.mtime asc
It will throw an error in the template itself, but work just fine in a note made from the template
@Aron-Polner oof, don't take my word for it, but you could create a user functions like
previousDate()
andnextDate()
, pull in moment-business-days using unpkg in your custom defined functions, and then add them to thetp.date
object (this object IS the moment object source).This should enable you to use them in your template accordingly to get that wrap around. I suspect it'll slow down templater launch on first go, however. YMMV