Dataview: How to find notes created on specific date

Things I have tried

What I’m trying to do

Hi everyone!

My first post since starting on the Obsidian journey (ex Notion user and loving it!)

I’ve been playing with Dataview and have managed to get it to do some impressive things so far, but my knowledge of combining Dataview with other aspects, like Template(r) are limited. I’ve looked through the dataview and templater docs but can’t work out how to do the following…

So I’m making a daily journal, title in format [[YYYY-MM-DD]] and want to use dataview to pull in all notes created on the date specified in the title. Issue is that I don’t always journal on the day that the title date of journal refers to. Essentially what i’m after is if I am completing a journal note for last friday, for example, then I want dataview to show notes that I created on that date (via the title, e.g [[YYYY-MM-DD]]. I want a separate table to show all notes that I modified on that date too. I just can’t get this to work

This is what I have so far for ‘created on date’:

TABLE file.ctime as “Created”
FROM “”
WHERE file.cday = date(this.file.name)
SORT file.ctime DESC

I’ve tried all kinds of variations lol.

Any idea?

Thanks
Sunny

1 Like

Well, with your query you get the files created on the same date of your daily note. You can replace your query by this (with the format “YYYY-MM-DD” you can get a date with the implicit field file.day):

```dataview
TABLE file.ctime as "Created"
WHERE file.cday = this.file.day
SORT file.ctime DESC
```

Your second point… well, you have a problem! Dataview results are dynamic: what you see is the “actual” metadata, when you run the query. It’s a “view”. Modified date is also a dynamic date. The value in file.mday or file.mtime change every time you made modifications to your file. Then, if you use a query with the modification date this value changes accordingly.
This to say that you can’t have a “stable” table in a specific daily note. If your goal is «know all the files that I modified in this date", if in the next day you modify a file in that list then the file move out from results in the previous daily note query.

1 Like

You are awesome! Thank you :slight_smile:
Yup, to the second point, the modified notes are just so I can track things i’ve worked on over the day in my journal so I can manually journal changes made to notes if needed… so it’s just a point of reference

Thanks again mnvwvnm!
S

Then you just need something like

```dataview
TABLE file.mtime as "Modified"
WHERE file.mday = this.file.day
SORT file.mtime DESC
```

note: attention to your quotations marks. you ned to use these ", not . maybe a OS language/keyboard in your side

Awesome, i had exactly that code in my dataview lol! I’m on the right track :slight_smile:

While I have you, one more qu if it’s okay? I’m using Syncthing to sync files across phone/tablet/server/desktop. They’re all linux based, but for some reason the 'created date sometimes changes. I think it’s related to when I add a new node to the network, not sure.

Either way, in my YAML I have a field for ‘created’, which stores data in the following format:


created: “2022-04-29 11:28”

I’d prefer to use that YAML field from my notes to compare against the date of the journal (using it’s title), but I’m not sure how to translate from YYYY-MM-DD to “YYYY-MM-DD HH:mm” inside the dataview codeblock without dropping the time. Any ideas?

Cheers

About sync issues, I don’t have any technical knowledge. I’m just a regular user with some knowledge in dataview acquired by the curiosity and experience. So, in that issue I can’t help.

About the created field, I don’t understand well your point (my bad).

  1. you want to use created instead the date in title (file.day)? Or in replacement of the file.cday?
  2. you want to use this field as date and as date+time?
    If you want extract a date and/or time from this field you need to use this format:
created: 2022-04-29T11:28

See the point about “Date” in the documentation: Data Annotation - Dataview

With this format, if you want to extract only the date (ignoring the time) you can use this function (there’s another one, but this one is more simple):

striptime(created)

see: Functions - Dataview

note: with this format you don’t need to use quotes. and, once again, attention to the quotes format. you can’t use curve quotes, only straight quotes

1 Like

you want to use created instead the date in title (file.day)? Or in replacement of the file.cday?

As replacement for file.cday… So based on what i’ve just learned, does this look right?

TABLE file.ctime as “Created”
WHERE striptime(created) = this.file.day
SORT file.ctime DESC

That does appear to work with created formatted like this:
created: 2022-04-29T11:28

:slight_smile:

yes, if you want to keep a field with date+time you need to use that format.
and if you want created as the creation time, you can also replace file.ctime by created

TABLE created as "Created"
WHERE striptime(created) = this.file.day
SORT created DESC

Yes!!! Thank you - Superstar :dizzy:

Hmm… I will be using created in the YAML in all files, so it makes sense to do it on both sides of the comparison i think

TABLE created as "Created"
WHERE striptime(created) = striptime(this.yaml.created)
SORT created DESC

You can’t use “this.yaml(created)” like that, but do you know how to write that correctly?

in the query syntax there’s no difference if the field is an inline-field or yaml. use just this.created

TABLE created as "Created"
WHERE striptime(created) = striptime(this.created)
SORT created DESC
1 Like

Fantastic, really appreciate your help bud, I’ve learned a tonne of useful stuff.

Hope you’re having a great day too
:heart: :smiling_face:

1 Like

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