# Automate dataview -\> plain text list / How to build a file.mdate-history?

**URL:** <https://forum.obsidian.md/t/automate-dataview-plain-text-list-how-to-build-a-file-mdate-history/52808>\
**Category:** Help\
**Tags:** dataview, daily-note\
**Created:** [January 21, 2023, 12:46pm UTC](https://forum.obsidian.md/t/automate-dataview-plain-text-list-how-to-build-a-file-mdate-history/52808 "2023-01-21T12:46:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lab](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/l/ba8739/32.png) [@lab](https://forum.obsidian.md/u/lab)\
**Post date:** [January 21, 2023, 12:46pm UTC](https://forum.obsidian.md/t/automate-dataview-plain-text-list-how-to-build-a-file-mdate-history/52808/1 "2023-01-21T12:46:49Z")

</div>

My goal is to use daily notes to keep track of which files I modified at a specific day in the past. So, I created a dynamically generated dataview table that accesses `file.mtime` and compares it to the respective day, e.g. for today’s daily note:

```plaintext
LIST
FROM ""
WHERE file.mtime >= date(2023-01-20) AND file.mtime <= date(2023-01-21)
SORT file.name

```

**The problem** with this approach is, that as soon as I modify a file again a few days later, it will disappear from this list, since `file.mtime` will get updated.

**Current work-around** is to manually highlight and copy-paste the dataview at the end of the day.

**Question:** Can this extraction of the dataview-table into plain text be automated?

(I’m also open to alternative approaches towards a file.mdate-history/logger.)

---

<div class="post-metadata">

**Author:** ![holroy](https://forum.obsidian.md/user_avatar/forum.obsidian.md/holroy/32/77699_2.png) [@holroy](https://forum.obsidian.md/u/holroy)\
**Post date:** [January 21, 2023, 5:37pm UTC](https://forum.obsidian.md/t/automate-dataview-plain-text-list-how-to-build-a-file-mdate-history/52808/2 "2023-01-21T17:37:43Z")

</div>

One way forward is to use _Templater_ to execute and insert the list into the note of your choice. This can for example be done in the javascript execution block, and triggering a dataview script.

Another option, building on the previous idea is to insert that code snippet into the creation og _next_ days daily note, so that it updates the content og yesterday’s note.

---

<div class="post-metadata">

**Author:** ![lab](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/l/ba8739/32.png) [@lab](https://forum.obsidian.md/u/lab)\
**Post date:** [January 22, 2023, 12:32pm UTC](https://forum.obsidian.md/t/automate-dataview-plain-text-list-how-to-build-a-file-mdate-history/52808/3 "2023-01-22T12:32:40Z")

</div>

Thank you for answering, @holroy . Maybe I’m overseeing something, but I am already using _Templater_ to dynamically insert the dataview table via my daily notes template, like so:

```auto
` ` `dataview
LIST
FROM ""
WHERE file.ctime >= date(<%tp.file.title%>) AND file.ctime <= date(<%moment(tp.file.title,'YYYY-MM-DD').add(1, 'd').format("YYYY-MM-DD")%>)
SORT file.name
` ` `

```

However, this still creates a _live-view_ dataview table, whereas, what I want to obtain is a plain text list, which will never be updated anymore. So how exactly would you make this conversion from dataview to plain text?

---

<div class="post-metadata">

**Author:** ![holroy](https://forum.obsidian.md/user_avatar/forum.obsidian.md/holroy/32/77699_2.png) [@holroy](https://forum.obsidian.md/u/holroy)\
**Post date:** [January 22, 2023, 8:43pm UTC](https://forum.obsidian.md/t/automate-dataview-plain-text-list-how-to-build-a-file-mdate-history/52808/4 "2023-01-22T20:43:42Z")

</div>

In this reply I’m answering on how to include stuff to be permanently saved into the new note, instead of being a dynamic query.

> [@How to add links to random notes to daily note](https://forum.obsidian.md/t/how-to-add-links-to-random-notes-to-daily-note/52379/6):
>
> I guess you didn’t see the note I made on tR, or understood it, for the following code only stores the result of the code into your new note: \<%\* const noOfNotes = 5 const files = app.vault.getFiles() for (let i = 0; i \< noOfNotes; i++) { const random = Math.floor(Math.random() \* (files.length - 1)) const randomNote = files[random] tR += `- [[${randomNote.path} | ${ randomNote.basename }]]\n` } %\> I’ve also included the option to specify how many ran…

So the gist of how to do this is:

- Use a Javascript execution command block, starting with `<%*`
- Do your query and store the result, using something like either `dv.query()` or `dv.tryQuery()`, see [Codeblock Reference - Dataview](https://blacksmithgu.github.io/obsidian-dataview/api/code-reference/#query-evaluation)
- And present the results back into the note by assigning the values into the `tR` variable, using something like `dv.markdownList()` to format the response.
- Alternatively, especially if you don’t want/need to handle the storage/evaluation of the query result (which I most often want to tinker a little bit with), you can also do something like `tR += await tryQueryMarkdown( ... )`(I’ve not used this one, yet, so not entirely sure of the syntax, but try it out) (This step would replace the two preceding bullet points

---

<div class="post-metadata">

**Author:** ![system](https://forum.obsidian.md/uploads/default/original/3X/b/e/bec35fbd23ab28909bb6bfe62cb32eb82dd34019.png) [@system](https://forum.obsidian.md/u/system)\
**Post date:** [January 29, 2023, 9:28pm UTC](https://forum.obsidian.md/t/automate-dataview-plain-text-list-how-to-build-a-file-mdate-history/52808/5 "2023-01-29T21:28:51Z")

</div>

Closed on January 29, 2023, 9:28pm UTC

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