A place to find and post code snippets used in the Dataview plugin created by Discord user blacksmithgu#1946.
Edit: In a recent update, various functions have been introduced! Checkout the docs to learn more about their usage.
Edit: I gave a live Obsidian Talk on the basics of Dataview, as well as some more advanced stuff. You can find the recordings of the live session here:
Part 1: Metadata and Basic-to-Intermediate Dataview
Using a dataview list is also a nice way to link to a note without creating an actual link. This can be useful if you want to link to a lot of notes without cluttering your graphview.
I use a snippet like this to show literature used in a specific project. I use it together with the great Citations plugin that creates literature notes with metadata like author, title etc. in the YAML frontmatter. When I use a specific source in the project, I tag it with e.g. #literature/thesis. This way I can create something like a preliminary bibliography for a project (translated to English from German):
```dataview
table authors as Author, title as Title, year as Year
from #literature/thesis
sort authors
```
I also use the following on my “Index” (kind of a start page) to show recently edited and recently created files (excluding the Index file itself):
```dataview
TABLE file.mtime as Edited
FROM ""
WHERE date(now) - file.mtime <= dur(3 days) and file.name != "Index.md"
SORT file.mtime desc
```
```dataview
TABLE file.ctime as Created
FROM ""
WHERE date(now) - file.ctime <= dur(3 days)
SORT file.ctime desc
```
```
Probably this will be more useful later, when live updating is added (it is on the roadmap on GitHub, if I’m right).
I don’t know who posted something like this first on the Discord, maybe it was @SkepticMystic?
Edit: There was a bug before version 0.1.8 that required to write >= instead of <= in the examples above. I now adjusted it to work in 0.1.8 and later.
Hi @phlind . I have modified the code from @liam and @SkepticMystic to get what I want on my Dashboards. You get the path and filesize. Date(tommorow) is much better then Date(today) as it will also give the files you created today.
TABLE file.mtime as Modified, file.size, file.path as Path
FROM ""
WHERE date(tommorow) - file.mtime >= dur(2 days)
SORT file.mtime desc
Hi @Ward, thanks for the tip with tomorrow, but I think what you mean is that it’s better than today. now also gives me the files just created/edited.
Would it be possible to create a dataview that creates an embedded list (ie which renders the page in preview mode) of files with a date title for each day, for use in a Daily Note. Phew what a sentence!
So, in a Daily Note: 1) an embedded link, 2) to other Daily Notes, 3) with the same date, 4) in previous years.
This would probably take a lot of work, and require the ability to write to notes; I don’t believe this is currently implemented. But I like the idea a lot!