Dataview date(today) alternate expression

What I’m trying to do

I have Daily Notes which are titled (e.g. for today) 2024-01-17
I use a Dataview query to list certain notes that relate to today or the last 24 hours. i.e.

WHERE file m.time = date(today) - dur(1day)

But when I go back a few days, of course (today) in the query is still 2024-01-17 and not the earlier date.

So I need an expression I can use instead of (today) which is the date (title?) of the Daily Note

Things I have tried

Things like {title}… but while this might have been lucky, it would never be fruitful. So I’m asking for advice on what an appropriate search expression – in place of (today) – would be, that would reflect the date of the Daily Note the expression was in.

When you’ve got a proper date in the file title, or in the date property, you can get this date using file.day. So you should be able to change date(today) with just file.day. Or possibly this.file.day if you want to use the date of the current file.

I have tried this on a past Daily Note with the title 2024-01-10. It already has a link to a file where I have added the property created_date: 2024-01-10 but the test is whether Dataview will pull it in.

```dataview
LIST
FROM #faith-fragment AND #incomplete 
WHERE file.ctime = this.file.day
```

with variants
WHERE file.ctime = file.day

and
WHERE date = this.file.day.

Another approach, to test the validity of the time part of the query was this:

LIST file.day WHERE file.day
 
SORT DESC
LIMIT 5

It brought up a lot of results but none on the day of that Daily Note.

I have studied the Dataview document and examples, with more patience than skill, but I would appreciate a steer on this desire to Dataview documents created on the same date as the Daily Note when a previous Daily Note is opened.

Try this:

```dataview
Table file.mday, file.day
WHERE file.mday > this.file.day
```

I made an example for you. Copy this folder in your root vault:
Daily.zip (930 Bytes)

Also you can test the output of the different date formats by copying something like this (I grabbed the trick from another post but don-t remember who was the author here’s the post):

`=date(today)`
`=date(now)`
`=localtime(date(now))`
`=this.file.mday`
`=this.file.day`

Very helpful, thank you so much

You’re welcome! Please remember to choose a solution for your question to guide others in the future. Thanks!

This pulls in EVERY date…

=date(today)
=date(now)
=localtime(date(now))
=this.file.mday
=this.file.day

In a table, these all show the month as “00” what ever the month is.

So I’m not quite at ‘solution’ yet!

Double check that you have a proper date in your title. Did you copy to your vault the example I made for you? that works as you asked. I just tested it:

Also you can copy this in any of your notes to understand which month is being pulled =this.file.day.month. In my example it will be: 1 (january)

Here’s your query example, slightly modified with my own choice of folder:

```dataview
Table file.mday, file.day
FROM "@FAITH-FRAGMENTS"
WHERE file.mday >= this.file.day
```

# Test Date formats
---
`=date(today)`
`=date(now)`
`=localtime(date(now))`
`=this.file.mday`
`=this.file.day`

and a screenshot which shows something strange going on with the date formats:

Just to take the conversation a little further, I would like to create a query that would list EVERY file created or modified on a particular day.

If I leave out the FROM “folder name” or just FROM “” I get everything!

This is relying on implicit creation and modified dates. I accept I may have to add these properties in YAML for my whole vault although I understood that Dataview would find the implicit data.

What is your take on this?

What is your date format? It seems like you’ve possibly mixed the Luxon tokens with the moment.js tokens, so how have you defined your date format in Settings > Dataview > View settings > Date Format ?

Here’s the screenshot:

Just for clarity, all ‘content’ notes in the vault have zettel or iso style titles e,g, “2024-01-24 etc etc” for today

That format is actually year + minutes + day, so switch to yyyy-MM-dd and it’ll look a lot better. :slight_smile:

1 Like

I would never have spotted that… thank you so much!

For the benefit of others, here’s what worked for me to create a list of notes created on the day of the Daily Note, and those modified on the day of the Daily Note.

This overcomes the overlap between Created Date and Modified Date — if you need to make the distinction and show modified ior edited notes in their own list:

#### Notes created today

```dataview
LIST 
WHERE file.cday = this.file.day
```
#### Notes modified today

```dataview
LIST 
WHERE file.mday = this.file.day WHERE file.mday !=file.cday 
```

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