Issue with daily created files: file.day contains unexpected value

Dear All,

I’m using Daily Notes (core plugin) and create daily files from a basic template, with name format “YYYY-MM-DD (ddd)”.

I then use queries to look at some info in daily note from the past 3 days:

LIST item.children.text
FROM #blah 
WHERE file.day > (date(today) - dur(3 days))
FLATTEN file.lists as item 
WHERE contains(item.tags, "blah")
SORT file.day DESC

This works most of the time, when the note is an auto-generated one on each current day. I then have no issue with file.day. However, if I plan something ahead and manually generate a daily note in the future (clicking on a future date in the calendar), it looks like the “day of the note” (not the created date file.cday, but well the date mentioned its title), gets the value of the created date.

Because of that, the above dataview query returns the 25 Feb note content (future data) while I expect past data.

For example: we are 20 Feb. I need to plan smth for 25 Feb, I click on 25 Feb and the daily note “2024-02-25 (Sun)” gets created. It obviously has an implicit field “file.cday” equal to 20 Feb. But I would expect this file to have an implicit “file.day” equal to 25 Feb, not 20 Feb.

I’ve read on Dataview documentation that:
" file.day Date Only available if the file has a date inside its file name (of form yyyy-mm-dd or yyyymmdd), or has a Date field/inline field. "

So the issue might be fixed by changing my daily notes name, but I really need to stick to this YYYY-MM-DD (ddd)

My questions:

  1. How can I manually check the implicit field of a note (like file.day)?

  2. How can I make sure that my query returns data from the past 3 days, and excludes notes created in the past but concerning a future date?

    • Should I add a additional criteria, “WHERE” file.cday is not in the future?
    • Should I add a specific field to specify that the note is from 25 Feb (and not 20 Feb)? How can I add such a field, so that it considers that the date is the 25 Feb and not 20 Feb?

Thank you!

Your query would list all files from three days ago, and to infinity! You don’t have anything limiting the query from displaying future plans using that date query. In addition your query always refers to todays date, so even if this query is run in a daily note from last year, it’s still referring to todays date, and will present those tasks.

Let us now tackle your specific questions:

Ans 1): You do check the implicit field file.day like you’ve done. And it’ll pick it up from your file names just as you expect it to.

Ans 2): This pertains to the part on using date(today), where I rather think you’d want to use date("2024-02-25"). That is you need your template to use the date as extracted from the file title, and not date(today) or file creation date and so on.

I’d also potentially add something like AND file.day <= date("2024-02-25") to avoid for a past note to include future stuff, if that make sense. I.e. do you want the 20 Feb note to include any 25 Feb stuff or not? If no, you need to add something like the above.

If you want to explicitly set the date to be used by file.day, you can set it as the date property in the file. The property will then override any date found in the file name.

Thanks so much @holroy ! You really are the one helping me out… fainng in love with Obsidian :wink:

Blockquote Ans 1): You do check the implicit field file.day like you’ve done. And it’ll pick it up from your file names just as you expect it to.

Even with a daily note with “(ddd)” in “YYYY-MM-DD (ddd)”?

If so, then indeed, my issue was purely with the date being " > " and therefore just including future stuff… Stupid of me :frowning:

For my understanding, how can I see the file (note) properties and potentially modify them?

Thanks again,
G

It should pick up the date no matter what other text is included. I just had it pick it up from f75733 with some text 2024-02-25 :smiley:

To see file properties you can either go to Source mode, or change the settings in Settings > Editor > Display > Properties in document to either Visible or Source.

Or you could open the command palette, and trigger the Properties view: Show file properties, which will open a pane in the right side panel showing the current file’s properties.

Thanks so much!

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