Dataview - file.day attribute

Hi,

After having looked art the details for the last two days I am sure that the error sits on front of the keyboard, but I seem to be blind and need some help, please.

What I’m trying to do:

Using data view, I am trying to list all notes in a specific directory which I have written on a certain day, e.g. I want to see all notes I have written yesterday.

What I have tried so far:

I have eight files I am testing with (all of them empty):
20221119 - test1.md
20221119 - test2.md
20221120 - test3.md
20221120 - test4.md
20221120 - test5.md
20221119 - test6.md
20221119 - test7.md
20221121 - another test note.md

From the data view GitHub pages, I understand that all files/notes that have the date in file title (of form yyyy-mm-dd or yyyymmdd), also have the attribute file.day. Above files fulfilled that requirement, if I am not mistaken.

Therefore I have played around with a dataview code as follows:

LIST file.day
FROM "1 aws/1 notes/1 meeting notes"
WHERE file.day = date(today) -dur(1 day)

Based on the files above I get following result:

image

Yesterday was 20th November - above results shows the file “20221119 - test 6.md”, which has apparently the attribute 20. November, which does not make sense as it clearly says in the file name 20221119, a date two days ago.

If I am changing the dataview code to this:

LIST file.day
FROM "1 aws/1 notes/1 meeting notes"
WHERE file.day = date(today)

the result I am getting is this:

image

This does not make any sense to me as well, as one file has todays date (November 21st) in the file name and therefore file.date should be November 21, 2022.

Funny enough, even when I play around with the number of days in the -dur() option I cannot get the files “20221119 - test 7.md” and “20221121 - another test note.md” to show up using any number whatsoever.

I am sure, I don’t see the forest for the trees, but I cannot get my head around this - please help :wink:

THANKS!

1 Like

First question: do you have any date: field in these notes?

image

No, and I was not planning to, considering the definition of file.day … in your example, did you use the date: field in the notes?

no. I just asked to eliminate a possible conflict.

Run this inline queries in the notes with date issues:

`=date(today)`
`=date(now)`
`=localtime(date(now))`
`=this.file.day`

Another thing: you can use date(yesterday) instead of date(today) - dur(1 day)

hmmm … this is really strange!
=file.this.daycomes up with all the correct dates.

However, when I write a new file with the file name 202211178 - test 10.md and I change the dataview code to -dur(4 day)it does not show the file. But when I write into the file =this.file.day and then run the dataview code again, it shows the file.

What am I doing wrong here?

something wrong with this date :slight_smile:

This is related with a strange behavior: if you create a new note but don’t add anything, it fails. You can add something and delete everything again and it will works.

In your test, when you add the dataview inline queries you’re adding some content…

1 Like

Yes :rofl: I made a typo in this message but the actual date in the file name was correct :wink:

Yes, that is the case – once whatever is added, it works, and it shows the file. Strange indeed, but now understood. That consequently means, that with every file generated, I need to make sure that something at the time of creation is being added.

Big thanks for your help!

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