Querying notes that haven't been modified in the past x days (not using file.mtime) but a frontmatter field

Things I have tried

What I’m trying to do

I want to visualize the notes that haven’t been checked in the past 7 days

I’m not querying by an implicit field (file.mtime) but by a frontmatter one named last_check::

I wrote the following query but isn’t yielding the expected result

table list from #A
where last_check and last_check < date(today) - dur(7 days)

Would really appreciate if someone could take a look

Thanks

Things to clarify:

  • what’s your value format in last_check?
  • it’s an inline or frontmatter field? (if a frontmatter field you just need to use “:”, not “::”)

last_check is a date, which I input through Natural Language Date plugin, meaning it’s in the right format

sorry for the confusion, it’s an inline field.

I don’t know the NLD plugin, but I guess it use multiple formats.
For dataview the right format needs to be in “yyyy-MM-dd”. It’s the case?

Debugging your query is always a good option, so I would try some variations of your query, to see that it actually uses the fields you believe it does.

So for starters I would do something like:

```dataview
table list, last_check, date(today) - dur(7 days)
from #A
```

For me with a small set of test files, this produced:
image

(Why is the list, in there? )

And then slowly add in the other bits and pieces, until you’ll get your wanted output. In my case, I added a where last_check, and that worked, so then I added a where last_check and last_check < date(today) - dur(7 days) and it also worked.

So it seems like it should work, but you might have some issue related to date formatting, so please check that and possibly run the query above and show us the output.

yep, right format

if so, it works fine:

This was the behavior I was expecting but it doesn’t render the expected result

Sin título

Thank you for your reply, I’ve uploaded I screenshot of my attempt in case you want to take a look.

Everything seems to be ok but it’s not working

It would be even more helpful, if you do the debug version without the where clause, and with the addition of the elements from the where clause as I suggested in my previous reply.

We know that for you the complete version doesn’t work, but we need more information to help you determine why it doesn’t work, and doing the query without the where clause, and adding those fields used, could be one way to enlighten us all.

And why do you have the list in there?

dates are links?

2 Likes

WOW

didn’t know that, why the query doesn’t work with linked dates?

because the type of data: strings are strings; dates are dates; links are links; numbers are numbers; :slight_smile:

1 Like

try where last_check and date(last_check.file.name) < date(today) - dur(7 days)

this only works if the date files exists. if not you need to use another strategy

That’s a good catch @mnvwvnm, which further illustrates why it’s so good to see the larger debug table so one could see which data is actually used in the queries!

1 Like

Yes, I use the same method: for any query I start always with a table :slight_smile:

what do you mean by larger debug table?

why’s that?

your date links exists?

See my first reply. It doesn’t limit the output so you get too much information, but it’s helpful to see that you actually get what you expect to get.

In your particular case, if we’ve seen that earlier on, we would have caught on the fact that your last_check inline field is actually links, and not just pure strings.

Doing debug variations of your table, is always helpful to properly verify that you actually get what you think you’re getting, instead of just assuming what you’re getting.

2 Likes