obsidian-dataview icon indicating copy to clipboard operation
obsidian-dataview copied to clipboard

file.day does not work

Open pbienst opened this issue 3 years ago • 3 comments
trafficstars

What happened?

I try to use the query below to get all the notes which are related to today. The query returns nothing, unless I replace .day by .cday.

Then, it lists filenames like

20220509 topic 1 20220509 topic 2

According to the documentation, those titles should be enough to populate the implicit field file.day.

Additionally, these files also all have the following in the frontmatter:

date: 2022-05-09T11:15

but still, that's not enough for file.day to be set.

The cday is only an imperfect workaround, as sometimes I create files related to earlier dates.

DQL

list
from "journal work" or "zettelkasten work" or "journal home/diary"
where file.day = date(today)
sort file.name desc

JS

No response

Dataview Version

0.4.26

Obsidian Version

0.14.9

OS

Windows

pbienst avatar May 09 '22 11:05 pbienst

How do you define "related to the current day"? Some examples would help. If the date field needs to be used, that's what we need to query IIRC. file.day is populated from file title IIRC.

AB1908 avatar May 09 '22 20:05 AB1908

Setting the date field should work; this may be a beta feature not available on 0.4.26, however.

In file titles, dataview should understand both YYYY-MM-DD as well as YYYYMMDD; however, the second syntax may also be a beta feature!

I'd recommend trying the beta or alternatively trying YYYY-MM-DD just to see if it works. I'll be marking the beta as stable soon otherwise.

blacksmithgu avatar May 10 '22 02:05 blacksmithgu

since we can set the date format in the dataview settings, can the title be recognized using the format we specify? rn I'm using 2022.08.27 and of course it's not picking it up, forcing me to add an unnecessary datapoint using the inline dataview

flygohr avatar Aug 27 '22 15:08 flygohr

The date format is only for rendering and not for parsing.

AB1908 avatar Oct 08 '22 20:10 AB1908

Hey @blacksmithgu Does dataview understand format DD-MM-YYYY ? I try to query and see all the notes created in the same date of the note title. cant resolve it

CyRamos avatar Oct 30 '22 16:10 CyRamos

Like I said above, it does not. You can, however, parse it yourself like so: date(join(reverse(split(file.name, "-")), "-")) and then manipulate it but it would be cleaner to be able to use Luxon directly like in #216. Closing in favor of tracking there.

AB1908 avatar Oct 30 '22 17:10 AB1908