I'm trying to setup a dataview query that shows notes created Today

Continuing the discussion from Dataview: show all files created at the same day and show the result in the daily note:

Hello,

I’m trying to setup a DV query as part of my Daily Note template; that would pull all of the new Notes created on the day of the Daily Note. I was trying to embed it in the template for my Daily Note. When I try to set it up, following the posts around here, I keep getting a full list of all of my notes that have “created” as one of the properties included in the note. The problem there is that all of my notes these days I include that property.

Any thoughts on how I can zero in on just the notes created for the day matching the date from the “created” property?

Here’s a screen shot of my template with the DV code I’m trying…

Thanks in advance.

P.S. - I’m totally new to experimenting with Dataview

I don’t really understand what you are asking and the problem but have you tried with this ?

```dataview
LIST
WHERE file.cday = this.created
```
1 Like

That totally worked! Thanks!

Now my question is what would the code look like if I wanted to have the property “created” show todays date…

And then create the query where it only returned those files that were created with the date specified in the property?

For example. I might create tomorrows daily note today, and then select the “created” date to be tomorrow. When I run the code you gave me, it will also show the Daily Note for tomorrow, which I actually created today.

Am I clear on what I’m asking? Here’s a screen shot of what was returend for today actually.

On the Daily Note for today (DEC 28th), You can see that one of the notes is actually tomorrows Daily Note titled “December 29, 2023 — Friday”. But that note has the property field “created” labeled with the 29th date.

Try this one:

```dataview
LIST
WHERE created = this.created
```
1 Like

BooM! You guys are Freakin’ Awesome! Thanks a Bunch!

Ok… now I’m really pushing my luck!

Is there a code to turn the list view into something that looks like this?

I use this:

table file.path, file.ctime
from “”
where file.ctime >= (date(this.file.cday) - dur( 1 day))
sort file.ctime desc
limit 20

Do you mean something like this:

```dataviewjs

const currentCreated = dv.current().created.ts

const result = dv.pages()
  .where(p => p.created && p.created.ts == currentCreated)
  .file.link

dv.span(`Created on this day: ${ result.join(" • ") }`)
```

Which displays as this with some random test data:
image

You could of course change what text you join the links with, and other texts as you like.

An alternate version of the query above reusing the DQL query from earlier, but adding the magic of joining the result:

```dataviewjs

const result = await dv.query(`
  LIST 
  WHERE created = this.created
    AND file != this.file
`)

if ( result.successful ) {
  const values = result.value.values
  dv.span(`Created on this day: ${ values.join(" • ") }`)
} else
  dv.paragraph("~~~~\n" + result.error + "\n~~~~")
```

This also excludes the current file, and adds a little bit of error processing. An advantage of this approach, is that if you don’t know a lot of coding, you could fiddle around with the DQL query until it displays the data you want, and then just insert that into the boilerplate code above and get the result joined up and displayed as you’d like. It also allows for extra processing, if that could be needed.

When one request is answered, it’s better to select a solution and start a new thread instead of introducing a new thing after the initial request has been answered.

1 Like

Got it!

Thanks for heads up on best practices. I’ll move that last post to new thread. Thanks for your help.

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