How to extract the day of the year as a number from title (YYYY-MM-DD)

What I’m trying to do

I am trying to get the day of the year as a number from the title of my daily page (YYYY-MM-DD)

Things I have tried

`= dateformat(<%moment(tp.file.title, "YYYY-MM-DD")%>, "ooo")` 

See my answer on the other thread with nearly the same theme…

The specific answer to this one:

`= dateformat(date(, "ooo") `
1 Like

Thank you, I learned this works:

<% moment(tp.file.title).format("DDD")%>

(notice the three 'D’s)

1 Like

Do note that ooo in moment tokens is padded to three digits, but DDD in Luxon tokens are just the day. To get it padded to three digits, try DDDD.

Also note that the my suggested solution using inline query on will follow the file name if it is renamed, and is in that sense dynamic. The Templater variant will not change if the file name changes later on, and as such is a static solution. Either one can be very useful depending on context and use case.

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