Templater parsing issue

I am a nube, and recently, and finally, sat myself down and begin to learn how to use Obsidian effectively. I have installed Obsidian on a Mac Air (the pc that I am working on presently) and a Windows pc. I have been using Sync, successfully.

I watched a video on templater and created a template for adding the date and title of the note, automatically. It worked like a charm, and I kept adding features to the templater script, building on each of the lessons.

Then, today, I accidentally over wrote the code in my template, thinking I was in my “learning” target note. I rebuilt the template, and typed in the code EXACTLY as the examples in the videos. I even build up a new “Date” template writing the code on the fly per the prompt notations from templater. I have tried more that a dozen attempts to no avail.

The code that blows out is as follows:

<% (tp.date, ‘YYYY-MM-DD’) %>

<% moment(tp.file.title, 'YYYY-MM-DD").format(“dddd, MMM-DD, YYYY”) %>

ALSO - When working, I couldn’t get the script to call the system time.

Any help would be appreciated.

Kind Regards,

Brooks

Try enclosing with the same symbol. Or apostrophe or quotes.

My bad, that is a typo. I got a phone call right in the middle of my writing my post. I’ll give it a try nevertheless…

Thanks (and standby :slight_smile: )

Well, there is good news, and bad news…

I made the correction as you suggested. I didn’t get a parsing error this time, but I did get an “invalid date” comment in-line in the note.

I copied-pasted your code and got characters other than apostrophe or quotes. Try replacing with these

(tp.date, 'YYYY-MM-DD')

moment(tp.file.title, "YYYY-MM-DD").format("dddd, MMM-DD, YYYY")

i did it, and it worked. Below are the results for the several attempts. I did get some parsing errors (Not shown), but they were the a result of experimentation.

The label YYYY-M-DD, assuming it is a label or sorts. Where this coming from? This s/b Daily Note titled with the current date. This will be used for all new notes, not just Daily Notes. Please note that I changed the Date template as follows:

<% moment(tp.file.title, ‘YYYY-MMM-DD’ ).format(“dddd, YYYY-MMM-DD”) %>

RESULTS (in order of revisions):

Friday, 2024-Feb-23, 2024

YYYY-MM-DD
Friday, 2024-Feb-23, 2024

YYYY-MM-DD
Friday, 2024-Feb-23

YYYY-MM-DD

Invalid date

YYYY-MM-DD

Tuesday, 2024-Jan-23

YYYY-MM-DD

Tuesday, 2024-Jan-23

YYYY-MM-DD

Lastly, I want to add time. I have tried H:mm, or HH:MM. all do not work.

Thank you in advance for your feedback.

-B

Try this:

dateF1: <% tp.date.now('YYYY-MM-DD')  %>
dateF2: <% tp.date.now("dddd, MMMM DD, YYYY") %>
date: <% tp.date.now("YYYY-MM-DD") %>
created_24h: <% tp.file.creation_date("YYYY-MM-DD HH:mm") %>
created_12h: <% tp.file.creation_date("YYYY-MM-DD hh:mm") %>
cdow: <% tp.file.creation_date("dddd") %>
uuid: '<% tp.file.creation_date("YYYYMMDDHHmmss") %>'

Very cool, thanks.

I see where I may have gone wrong. I will play with this later tonight.

Do note that if you want to use the date fields in dataview you’re better off using tp.file.creation_date("YYYY-MM-DDTHH:mm"), since that T will make it be recognized as a date without any more work.

my error. figured it out

That’s interesting. I will be needing to capture a date and timestamp in a record format.

For the past 25 years I have been using canned RDMS as Paradox, and then Microsoft access. I wanted to migrate to ‘pure’ MySQL, or SQL, but now I see the power of Obsidian. (My first interest in Markup languages began in the 1980’s with iLeaf publisher, then SGML in the mid 1990’s. I never took it further because I didn’t have a good parser. I was spoiled by Interleaf.

I would like to migrate all of my work to an Obsidian vault.

The object would be organize and analyize in Obsidian, and publsih.

Any thoughts?