Templater "Created" and "Modified" dates suddenly started having problems

That works perfectly, thank you! :pray:

I also noted in the discussion you linked to that the use of the dynamic Templater code may get deprecated at some point, so it was a good exercise (for me) to make the switch now.

FWIW, I have this at the start of every note. (It’s a combination of an Admonition callout and the info I had that showed date created, modified and file path - now updated to use Dataview.)

```ad-info
collapse: open
**Created**: `=dateformat(this.file.ctime, "DDDD, HH:mm")`
**Modified**: `=dateformat(this.file.mtime, "DDDD, HH:mm")`
**Location**: `=this.file.path`

Which results in something like this. (This is what I see when I’m editing the template file for notes related to apps.)
image

And just for comparison: the file path on the note I have for Affinity Designer.
Screenshot 2022-12-30 212219

2 Likes

Great!

The Admonition looks good.

Yeah, <% tp.file.creation_date("") %> still works fine in Templater (as the creation date never changes), but after the dynamic commands ( <%+ ) stopped working, I thought: how much do I really switch to Reading mode to look at those anyway? Dataview for the win!

1 Like

Hi guys,
I´m quite new to obsidian so apologize my question.
I had the same issue wiht the modified date and tried now your solution using Dataview, the coding

updated: `=dateformat(this.file.mtime, "DDDD, HH:mm")`

doesn´t work.
I have other dataview codes in my files that are working fine, so I´m wondering if you have any idea on what the issue could be.

Have you turned on inline queries for dataview? I think they’re disabled by default.

yes it is

I use for instance

not done
due before <% tp.date.now("YYYY-MM-DD") %>

for my daily notes and it works great

Could it be because of a different date format I´m generally using?

Those are not dataview queries, rather tasks query.

Please go into Settings > dataview, and check for online queries

1 Like

Could you make a screenshot maybe of how it looks in edit view in your vault so I could compare the exact syntax?
As mentioned, I´m true freshman

As holroy said, this isn’t a dataview query.

My Dataview settings screen looks the same as yours. What does

`= this.file.name`

produce for you? It should return the file name.

It returns the file name…
I found my mistake, thank you so much guys.
I thought I need to embed the query into “```”.
image
Could you please explain to me why for the above code I need to embed this while for the simple dataview query I don´t?

To your original issue, try pasting

`= dateformat(this.file.mtime, "DDDD, HH:mm")` 

into a note again. What does it return? How doesn’t it work? If ‘this.file.name’ works, I’m at a loss why ‘dateformat…’ wouldn’t.

So, many plugins utilise the code block to enclose their query or input. This applies to tasks, dataview, admonition, and many others. A code block is a block of lines surrounded by three (or more) backticks, ```, (or tildes, ~~~).

These blocks are also used for presenting code from various programming languages, and I think why they are used for plugins is their ability to contain many lines of text, and a built-in feature for tagging the block with a name which is easy to get at and used by the markdown processor.

However, in this thread we’re not talking about just a query, but an inline query. This is a special case made to be used in line with text of a paragraph.

This requires a different syntax, and the base syntax is yet again inspired by the one used from presenting code within the paragraph, which is single backticks around the phrase, like `…`.

And finally to identify that code as an inline dataview query, that code phrase has to start with the equal sign, =, so it becomes: `=…`.

1 Like

It works fine now, I just used the inline query wrong

Thank you so much for the explanation.
I indeed need to learn still a lot

Is there any update by now how to make it function again in the frontmatter?

If you are referring to the Templater NaN issue, I would check their GitHub page for any updates on the issue.

It seems the issue you pointed out is still open (as of today).

Therefore, I changed to Obisidian Linter, which I can personally recommend and which worked without problems for me.

1 Like

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