Help trying to get dataview to pull from YAML for the next 7 days from daily notes

Things I have tried

I have templater configured for both weekly and daily logs, I have also setup some front matter to capture a daily summary and what I would like to do is pull those daily summaries into my weekly log via a dataview query.

Front Matter has summary setup, daily notes are configured in their own folder with title as date format of YYYY.MM.DD.

Tried using the following based on some other queries but I am stuck, still learning obsidian and not much of a programming background.

Table 
Summary
FROM "04_daily Logs"
WHERE file.name >= this.file.cday + dur(7 days)
sort file desc

Thanks for any help or insight.

Hi.
To start: YYYY.MM.DD ins’t a valid date format; you need to use YYYY-MM-DD.
https://blacksmithgu.github.io/obsidian-dataview/data-annotation/#field-types
Second point: file.name is a string, not a date type; even if the title is in YYYY-MM-DD format, if you call the file.name you get a string, not a date.
In this cases you can use two ways:
a) apply a date() function to the file.name - date(file.name)
b) when in title there’s a date in YYYY-MM-DD or YYYYMMDD you can use the implicit field file.day - Data Annotation - Dataview

You can make date comparisons only if the values in stake are in a recognized date format or are an implicit date fields (as file.cday, file.day, file.mday, etc).

Thanks for the quick response and help @mnvwvnm

I will update my template date format and then update my query.

I was able to get it working based on your suggestions. Thanks for the help @mnvwvnm

*** Solution:
Renamed the files to use the YYYY-MM-DD format, then updated the query as noted below.

The output now displays what I am looking for.

Table Summary, keywords AS "keywords"
FROM "04_Daily Logs"  
WHERE file.name >= this.file.cday + dur(7 days) AND Summary
AND date(file.name) < this.file.day
Sort desc

hmmm. I don’t understand this part:

  • WHERE file.name >= this.file.cday + dur(7 days) AND Summary AND date(file.name) < this.file.day

1 - file.name is a string
2 - this.file.cday + dur(7 days) gives you a date
3 - <string> >= date doesn’t work!

If your Daily notes title are in format YYYY-MM-DD and the note where you run the query have the same title format, you can use
WHERE file.day >= this.file.cday + dur(7 days) AND Summary AND file.day < this.file.day

If you want to use the file.name, to be valid as a date you need to use date(file.name) in both places, not only in the second.

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