Create a static (?) date on daily notes in Dataview or Tasks that doesn't change with new date

What I’m trying to do

I’m using Daily Notes, where a new one is created each day upon startup of Obsidian. In my daily notes I’m using Dataview and Task plugin queries to show me the tasks that I have set up for that day. For example, my “tasks due today” looks like this:

(due today) OR (scheduled today)
short mode
hide task count
hide due date
hide tags
sort by status
sort by priority

This works great to show the tasks that I have due for that current day that the Daily Note is created for. But I’d like to keep a repository/record of tasks in my daily notes to show what was completed on those days by making it so that the date in my query stays the same as the day changes. For example, if today is May 18, the (due today) query will show me the tasks due for the current day, May 18. But when the next day, May 19, comes about, and I go to my daily log for May 18, the May 18th Log now shows the tasks due for May 19, since that’s technically the current day. I’d like that date to automatically change so that tasks due May 18th are shown on May 18th after that day has passed.

I hope that makes sense. I’m sure there’s a way to do it, but I haven’t been able to find the solution in my searches, and would appreciate some help here.

What you want is to end up with something that looks like this:

(due 2024-05-18) OR (scheduled  2024-05-18) 
short mode 
hide task count 
hide due date 
hide tags 
sort by status 
sort by priority

Essentially, you want to “hard code” the date in the daily note and not use “today”. This seems to work:

(due <%tp.date.now("YYYY-MM-DD", 0, tp.file.title, "YYYY-MM-DD")%> ) OR (scheduled <%tp.date.now("YYYY-MM-DD", 0, tp.file.title, "YYYY-MM-DD")%>) 
short mode 
hide task count 
hide due date 
hide tags 
sort by status 
sort by priority

There’s probably an easier way get the filename of the daily note, but this is what I got to work. Regardless, the key is that when you create the daily note you want to use use the actual date and not “today”

1 Like

I knew there would be an easier way to get the note name, just remembered you can use tp.file.title instead of the tp.date.now(…). That assumes the note title is something like 2024-05-18

Both of those ways worked perfectly! I had a little trouble at first, but then renamed my daily log template just YYYY-MM-DD and after that both those solutions you gave me worked. I really appreciate the help on that! It’s so nice now opening my daily note and everything already being there and organized and not having to manually change the dates every date!

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