How to retrieve creation date from Metadata of a note

Things I have tried

Searched for a solution here and in the help vault without success.

What I’m trying to do

Hi,
I would like to automatically ad the creation date (and modification date where applicable) of new and existing notes in the front matter.
I know how to insert the creation date via a template and the {{date}} syntax when creating a new note but I have no idea how to retrieve the dates from the meta data for already existing notes.

Thanks in advance for any help.

These work?

`=this.file.name`
`=this.file.cday`
`=this.file.ctime`
`=this.file.mday`
`=this.file.mtime`

Angel

No, unfortunately it doesn’t.

I imagine that you could choose either of two options

  • install dataview, and then paste Angel’s codes, switch to Read Mode, and you should have what you want.
  • install templater, visit the templater documentation page, and find out how to do what you want using the examples on the documentation page.

The advantage of the templater option would be that the code would paste the actual date. Whereas the Dataview option can render the date from the note’s metadata but only whilst in read mode.

Good luck!

1 Like

This?

If you are using Templater, you could create a new supplemental template with the following lines:

creation_date: <% tp.file.creation_date() %>
modification_date: <% tp.file.last_modified_date("dddd, Do MMMM YYYY, HH:mm:ss") %>

You can then go to existing notes, put your cursor in the YAML header and invoke the new template.

The creation and modification date will be added to the YAML. The modification date won’t be dynamic.

Test it on a sample file first.

Angel

1 Like

Hi all,
I decided to use the Templater Plug-in and found a good solution for me (see screen shots):

So thanks a lot everybody for your help.

PS: @Angel, if I put the template for the modification date in the frontmatter, it will not be updated correctly. Therefore I use a private block with a small table right below the frontmatter block. I think it looks pretty nice especially because I use the cssClass “table-tiny” in the frontmatter for all my tables.

Good to hear you found a solution that works for your needs.

Angel

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