Dataviewjs query re yesterday's notes

What I’m trying to do

Trying to see a list of all notes modified between 12 and 36 hours ago.

Things I have tried

I put a query into ChatGPT and got the following code:

$=dv.list(dv.pages, [[Your Notes Folder]])
.filter(file => date(today) - date(file.mtime) <= 3660601000 && date(today) - date(file.mtime) >= 1260601000)

But it doesn’t work. Just wondering if anyone can see what’s wrong.
I have a dataview query that works but I’m trying to put this on my homepage which seems to require dataviewjs.

Try something like this if you want to establish a range of hours:


```dataviewjs
dv.list(
  dv.pages()
    .where(n => 
	    n.file.mtime >= dv.date('now') - dv.duration('36h') &&
	    n.file.mtime <= dv.date('now') - dv.duration('12h'))
    .file.link
)

```

But if it’s only to visualize notes modified yesterday, maybe you can use:

```dataviewjs

dv.list(
  dv.pages()
    .filter(n => 
      n.file.mtime >= dv.date('yesterday') &&
      n.file.mtime < dv.date('today'))
    .file.link
)

Thanks so much. Both snippets work beautifully!
One question: How do I get files from a specific folder or two?
The help page says: dv.pages(‘“folder”’) => all pages from folder “folder”
Codeblock Reference - Dataview (blacksmithgu.github.io)

So I tried this for my _Zettelkasten folder with no success:

	dv.list( dv.pages('"_Zettelkasten"') => all pages from folder "_Zettelkasten_" .filter(n => n.file.mtime >= dv.date('yesterday') && n.file.mtime < dv.date('today')) .file.link )

You’ll need to loose the comment of "=> all pages from … ". So it reads something like:

dv.list( dv.pages('"_Zettelkasten"').filter(n => n.file.mtime >= dv.date('yesterday') && n.file.mtime < dv.date('today')) .file.link )

Is this an inline query or a dataviewjs query?

Thanks a lot. Yea, I just got it working before your reply.
It’s a dataviewjs query.
I appreciate your time!

Nice to read it worked for you! Remember to choose a solution to guide others in the future.
Thanks!

ChatGPT isn’t a good source of info for this sort of thing. Its wrong output won’t help anyone who has the knowledge to help you, and it’s not worthwhile to debug it because the answer to “what’s wrong” will generally be “ChatGPT made up some nonsense”.

(The structure of your post didn’t center “what’s wrong with ChatGPT’s code”, so it’s not a big deal here.)

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