How to use a inline field "created time" instead of "cday" in Dataviewjs?

Hello there, I’m using a dataview script from Blue topaz’s example vault which list notes that created today.

```dataviewjs
const filename=dv.current().file.name;
dv.list(dv.pages().where(p => p.file.cday.toISODate() === filename).sort(p => p.file.ctime, 'desc').file.link) 

This works well at first on my main PC, but when I sync notes to my laptop ,somehow some notes changed created time to today and this script list all those notes which shouldn’t have.

To my knowledge this caused by file.cday , so I want to use my own inline field created which created with Templater

created: <% tp.file.creation_date("YYYY-MM-DD HH:mm:ss") %>

I know little about programing, and I tried to replace p.file.cday.toISODate() to p.file.created but didn’t get it work.

Can anyone help or any advice? Thank you for your help.

For starters I do believe you need a capital “T” in your format for the date to be a compliant ISO date according to dataview.

So try doing tp.file.creation_date("YYYY-MM-DDTHH:mm:ss") or tp.file.creation_date("YYYY-MM-DD[T]HH:mm:ss") in your template, and verify that it produces the wanted 2023-10-04T08:48:10 output, and whether that solves your issue.

Please report back on any progress

You need to use p.created instead of p.file.created.

1 Like

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