Wrong Creation Date Properties / Dataview lists wrong date

Hi Guys,
I am a super beginner with Dataview and I have searched extensively, but I couldn’t find any solution. I would appreciate any help as it gets very confusing. :pray:

I regularly write video scripts in Obsidian and use a “Creation Date” in my Properties (Property Type “Date”) to tag the date my script was written.

Sometimes I have to modify it to a certain date, depending on the project. Sometimes things got written by hand and I have to choose the right day in tha past. So I have to change the date retrospectively regularly.

Initially, I tried using ‘file.cday’ to list scripts by this property, but it doesn’t align with the creation date added in the properties. It seems Obsidian pulls the real note creation date.

Right?

So, I’m seeking a solution to list scripts based on my ‘Creation Date’ property.

This is how my note Properties look like:

---
Creation Date: 2024-03-06
Area: "[[%CRAFT]]"
tags:
- craft
 - script/draft
---

and this snippet doesn’t work:

TABLE Creation Date as "Created"
FROM #script/draft and -"03. Resources/templates"
SORT file.ctime DESC

Where am I misinterpreting Dataview and YAML/Properties?

Here some examples how dataview lists the original but not the property date:


Any ideas or recommendations would be highly appreciated.

Thank you.

I think the space between Creation and Date could be the culprit :thinking:

It’s generally not a good idea to use “space separated multi-words” key names :sweat_smile:.
It’s not a bad idea either… but it just adds an unnecessary thin layer of complexity down the line :innocent:.

Instead, one can use Camel Case (creationDate), Pascal Case (CreationDate), Snake case (creation_date), and alike… (avoid using numbers with Kebab Case (creation-date) though … I run into similar issue with that :innocent: ).

Fortunately, Dataview also provides a workaround for this type of use case scenario, as it also stores, within the file object, a Kebab case version of the keys used in Properties… Meaning that your Creation Date key can be used as creation-date within the query :blush: .

Another way to get there would be to use row["Creation Date"] instead of Creation Date as it is.

Here’s a link to the relevant documentation: How do I access fields with spaces in the name? :blush:

So, for your query, this:

```dataview
TABLE creation-date as "Created"
FROM #script/draft and -"03. Resources/templates"
SORT file.ctime DESC
```

or this:

```dataview
TABLE row["Creation Date"] as "Created"
FROM #script/draft and -"03. Resources/templates"
SORT file.ctime DESC
```

Should give you the expected results :blush: .

As for this:

Yes, file.ctime, file.mtime, file.cday, file.mday are all referring to moment the file was created/modified on your system/file explorer which can be unreliable (as it can sometimes, under certain conditions, be overridden AFAIK).

5 Likes

This is so incredibely helpful. Thank you so much!

I didn’t know about the multi name keywords, but I will change it for the future.

Both of your queries worked! :pray:

Thanks again!!

1 Like

My pleasure :smile: !

I’m very glad to know it helped you move forward :grin: !

1 Like

Although the notes done by @Pch regarding how to address field names with spaces in are correct, the sort order of your files and what you display are still two different things in a query like:

```dataview
TABLE row["Creation Date"] as "Created"
FROM #script/draft and -"03. Resources/templates"
SORT file.ctime DESC
```

This will still sort on the file creation time, and display the Creation Date field. As such, you might still run into issues if we these values don’t correspond. So a better query would be to use:

```dataview
TABLE row["Creation Date"] as "Created"
FROM #script/draft and -"03. Resources/templates"
SORT row["Creation Date"] DESC, file.name ASC
```

Or similar variations using the same field for both display and sorting. I’ve also added a secondary sort on the file name, just in case you’ve got multiple files on any given date.

2 Likes

Great, thank you! :pray: :pray:

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