Dataview variable to return notes created today (as a variable)

What I’m trying to do

Can anyone tell me if there is a variable I can insert into this dataview query to replace the date so that when I open the note I will always see the notes created on that particular day.

LIST
WHERE contains(creation-date, “2024-01-31”)
SORT file.name DESC



### Things I have tried

I looked at a couple of other threads here but didn't find anything I could use.

<!-- Below this line, write what terms you searched in the help docs and forum, plus any solutions you tried and what happened. -->

Since you have a standard date format, you can simply use this:

```dataview
LIST
WHERE contains(creation-date, date(today))
SORT file.name DESC
```

And, an advice, if you want to write a code block in the forum like this, yous can write like this:

```
the code block
```

If you want to display the ticks, you can write:

````
```
the code block
```
```` 

Thank you for the tip on displaying code. When I used the dataview query syntax you suggested, I got the attached result.

One more piece of info - my creation date property is formatted

creation date: YYYY-MM-DD HH:mm

So this works normally:

LIST
WHERE contains (string(creation-date), string(date(today)))
SORT file.name DESC

Many Thanks!

Note that dataview is somewhat picky about the date format, so what you presented is actually not a date, but just a string.

You can coerce it into a date, with presenting a new date format, but it’s not considered a date by default due to that space between the day and time part. So something like date(creation-date, "yyyy-MM-dd HH:mm") should turn it back into a date again for use in your query.

1 Like

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