Filtering Dataviewjs Query by Date Property

Hello! This is my first post in the forum.

What I’m trying to do

I have a dataviewjs query that I am hoping to filter to notes within the last 10 days.

Here is what I have so far:

dv.list(dv.pages().file.lists.where(t => t.text.includes("#done")).map((t ) => t.text))

This works great; it generates a list of all instances of #done in my vault.

What I’m struggling to do is add another .where requirement to this existing code. I would like it to only show instances of #done from pages where the date property is 10 or fewer days ago.

Things I have tried

I looked at this thread but my lack of coding knowledge prevented me from applying the example to my existing code. I think it would include something like:

.where(t =>'today') - < 10)

But I’m probably way off base. I appreciate anyone’s help!

Most likely you added the extra .where() after the .map(), and that won’t work as you’ve stripped away all the other variables. If this is the case, try move the extra .where() before the .map(), and see what happens.

If you’re unsure on what your code would return it’s a good idea to get used to using console.log() to print debug information, and/or to include the new variable/conditions as separate columns.

Lastly, you’ll most likely need to do something else rather than just subtracting dates directly, which wouldn’t return a number to compare against. You might either look into durations, or possible extracting the .ts part and divide it up to get the number of days.

Thank you, holroy! I couldn’t figure it out, but I ended up with an acceptable workaround. I limited the results to the six most recent notes with the tag:

 dv.list(dv.pages().sort((page) =>, "desc").file.lists.where(t => t.text.includes("#done")).limit(6).map((t ) => t.text))