What I’m trying to do
I have a Daily Notes template in which Templater on creation of a Daily Note puts the creation date of the file retrieved from the Linux bash date command using Templater user functions.
It looks like this:
---
creation-date: <% tp.user.systemdate() %>
modification date: <% tp.file.last_modified_date("YYYY-MM-DD HH:mm:ss")%>
---
The systemdate function looks like this:
date '+%Y-%m-%d %H:%M:%S'
The result looks like this:
---
creation-date: 2024-01-23 21:29:02
modification date: 2024-01-23 21:29:02
---
Note that the creation-date field is a TEXT object, NOT a DATE object. I’m not sure how to create a date object from the text output of the system command.
I have a Weekly Notes folder contains one note for each week which uses the same format. In each weekly note I have a query that I want to run which does the following:
List all the Daily Notes that are for the same year, same month, and same week as the weekly note.
Things I have tried
Absolutely everything for the last 12 hours.
Here is the problem:
In the WHERE clause, I can easily convert the creation-date object from each Daily Note into a date object and extract the year or the month or the week for comparison purposes.
What I can’t seem to figure out is how to convert or otherwise format the text property of the Weekly Note file into a format that will compare to either the text string of the incoming Daily Note file or the converted date object of the incoming Daily Note file.
I have tried doing date conversion of the Weekly Note creation-date field and it always tells me it can’t parse the date string. I’m trying to separate out the year, month and day with three separate compares and it just doesn’t work.
I originally tried using this query:
```dataview
LIST
WHERE date(creation-date,"yyyy-MM-dd hh:mm:ss").year = this.file.ctime.year
AND date(creation-date,"yyyy-MM-dd hh:mm:ss").month = this.file.ctime.month
AND date(creation-date,"yyyy-MM-dd hh:mm:ss").week = this.file.ctime.week
SORT title ASC
Limit 300
That worked fine - until I had to reinstall the OS, and restore Obsidian from the backup. Now ctime - which is almost useless because most of the Linux filesystems do not recognize ctime as a valid date - is set to 1969. Template’s file creation date function picks up the wrong date as a result, which is why I’m using the bash system date which looks to the right system function to produce a correct “birth date” (as it’s called.)
So I have to use the creation-date in the YAML front matter to do comparisons. But I can’t figure out how to reference the creation-date field in the Weekly Note so that I can compare it to the creation-dates in the Daily Notes.
I’m beginning to think I can’t really use any of these “built-in” or “plugins” at all because they invariably require a day or more of research and figuring out how the functions, literals, etc. of Dataview fit together is a nightmare.
Which means please don’t suggest that I do anything with JavaScript or or Dataviewjs queries because I’m not going to spend days learning JavaScript right now.
i want a reasonably simple solution that simply compares to string dates. Something like:
WHERE incoming.file.creation-date.year = this.file.creation-date.year
Which unfortunately is not valid syntax - which is the problem.
Any help appreciated. Thanks in advance.