Query for dates that are actually links (dataview)

Is it possible to query for dates that are actually liks with dataview?

I have 2x data metadata fields that are actally links (due-date:: [[2022-02-17]]) and would like to do the following queries on them from within this day’s note:

WHERE due-date <= date(this.file.name) AND due-date
WHERE due-date = date(this.file.name) + dur(1 day) AND due-date
WHERE due-date >= date(this.file.name) + dur(2 day) AND due-date <= date(this.file.name) + dur(7 day) AND due-date

I see the issue coming in where I want to do “calculations” and “comparisons” with the field.

I was thinking of using the link(), string() and date() functions, but the issue comes in with comparing to the value in the actual action.

Thanks in advance!

try this:

WHERE due-date
WHERE date(due-date) <= this.file.day

1 - with date(due-date) you convert the link (due date is a link) in a date;
2 - as your files are daily notes with titles in the format “YYYY-MM-DD” you can use the implicit field file.day, that extract the date from the file name (attention, to not create any conflict, don’t use any field with the name Date::).
https://blacksmithgu.github.io/obsidian-dataview/data-annotation/#implicit-fields
3 - you can do the other “calculations” with file.day: WHERE date(due-date) = this.file.day + dur(1day)
4 - you can use multiple WHERE conditions. They work as multiple “AND”.

1 Like

1 - oh wow thanks. I didn’t think that I could pass the key into the date() function.
2 - I also tried WHERE date(due-date) <= date(this.file.name) which also worked out for me. I’m not sure how the implicit file.day works / where it gets the date from. I see in the docs it’s described as a “An explicit date associated with the file.”
3 - :+1:
4 - great! I didn’t know that, that certainly cleans up my queries a bit

file.day gets the date from:
1 - file title if any part have the format yyyy-mm-dd (for example: [[2022-02-17]], [[My file with date 2022-02-17]], [[2022-02-18 Friday]], etc.)
2 - field named Date (if you use in your note a field as Date: 2022-02-18

A suggestion: use this inline query to check how metadata is structured in your file:

`$=dv.span(dv.current())`

Thanks for the explanation.

OMG that snippet :exploding_head: is awesome!

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