How to use Dataview to show all Diary sections from daily notes in a specific year?

Hi everyone,

I’m new to Obsidian and I’m trying to use Dataview to create a query that will show all the Diary sections from my daily notes in a specific year. Here’s what I have so far:

LIST from "2023-01-01" to "2023-12-31" WHERE file.name =~ /.*\d{4}-\d{2}-\d{2}\.md/ AND section("Diary")

However, this query doesn’t seem to be working for me. I have a daily folder where each daily note has a title that includes the date in the format “YYYY-MM-DD”. Within each daily note, there is a section called “Diary” where I write my daily reflections.

Can anyone help me figure out what I’m doing wrong with this query? Or suggest a better way to accomplish what I’m trying to do?

Thank you in advance for your help!

1 Like

Hello.

So much depends on how your files and data are structured. Sample folder and query in the zip attached.

2025v.zip (4.4 KB)


may daily is like this! ur code does not work!! what should i do?

Tasks

  • [ ] Task 1
  • [ ] Task 2
  • [ ] Task 3

Notes and Thoughts

  • Write down any ideas, thoughts, or observations you have throughout the day.

Events and Appointments

  • [ ] Event 1 (Time/Location)
  • [ ] Event 2 (Time/Location)
  • [ ] Event 3 (Time/Location)

Diary

  • Write about your personal reflections and memories from the day.

Dataview is not able to pull out the text from a section in a note. It’s used to list fields and metadata from the notes, or potentially text from a list or task item.

  • That syntax using from ... to ... is not legal in any way. The FROM ... can be used to define the source folders (or tags) of the notes you want to query.
  • If you want to do regex matching, you need to use a function call like regexmatch(file.name, "...regex...").
  • There is no function named section() in a DQL query.
  • To query related to the date of your notes, you might use file.day and compare to some variant related to date(now) and dur(...) to get to a year old notes
  • If all of your reflections and memories are written as list item, there was a similar request just a few days ago which you could try to adapt to your needs.
  • If on the other hand, your daily notes also include pure text, you need to use javascript to extract that text.

In summary, I think you really need to read up on doing dataview queries, and try something simpler, and take it step by step. And do some research by searching this forum for similar solutions.

1 Like

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