I have a dataview table that queries all files inside a folder. inside each file there is a key representing a date. DATE::YYYY-MM-DD
I want the file’s query to be shown only if this condition is true: the DATA key should be earlier than today’s date.
I tried this code but it doesn’t work:
##TABLE
##...
##FROM ...
WHERE DATE < date("today")
Unfortunately, It has no effect on my dataview table:
TABLE WITHOUT ID
file.link AS Files,length(filter(file.tasks.completed, (t) => t = true)) AS Completed, length(file.tasks.text) as Total, "<progress value='" + (length(filter(file.tasks.completed, (t) => t = true)) / length(file.tasks.text)) * 100 + "' max='100'></progress>" AS Progress
FROM "FOLDER"
SORT IMPORTANCE DESC
WHERE DATE < date(today)
The query below works in any file in any folder in my vault.
If the DATE:: value is today’s date, the name of the actual note will not appear in the query.
If the DATE:: value is changed to being before today’s date, the name of the actual note will appear in the query (Dataview needs a few seconds to update).
Does it work for you?
DATE:: 2023-07-05
```dataview
TABLE WITHOUT ID
file.link AS Files,length(filter(file.tasks.completed, (t) => t = true)) AS Completed, length(file.tasks.text) as Total, "<progress value='" + (length(filter(file.tasks.completed, (t) => t = true)) / length(file.tasks.text)) * 100 + "' max='100'></progress>" AS Progress
WHERE file.folder = this.file.folder
SORT IMPORTANCE DESC
WHERE DATE < date(today)
```
Here is an example of three variants which all should work. The last example consists of the last column, and the FLATTEN statement.
```dataview
TABLE WITHOUT ID
any(map(date, (d) => d < date(today))),
filter(date, (d) => d < date(today)),
any(earlierDates)
FLATTEN array(map(date, (d) => d < date(today))) as earlierDates
```
If you’d want to use this not only for display, but also for grouping or where clauses, I’d use some variant of the last one to repeat the condition.
The filter variation, opposed to the two other, returns just the matching date(s).
Note that in addition to any, it’s also possible to use none and all, for their variants in required values.