New Properties Editor can't change Date or Time field formats

Dates are not working in YAML. You can’t change the property type between Date and Time, and using the API to set metadata with (YYYY-MM-DDTHH:mm) or (YYYY-MM-DD) just sets a text field in YAML without parsing it as a Date or Time field (although sometimes YYYY-MM-DD gets set as a Time field, but still not a Date field).

Did you follow the troubleshooting guide? [Y]

Steps to reproduce

Copy the following code into a note:

---
Date field: 2023-07-29
Time field: 2023-07-29T10:00
Text field: text
---

Then try to change Date field to a Date and Time field to a Time. They don’t display the correct types:

Expected result

  • Being able to change property values to date and time (reformatting the YAML if necessary)
  • Automatically parse YYYY-MM-DD HH:mm or YYYY-MM-DD as a date or time field.

Actual result

  • Dates are parsed as text fields
  • You can’t change text fields to Date or Time fields, or Date/Time fields between each other

Environment

SYSTEM INFO:
Obsidian version: v1.4.1
Installer version: v1.3.5
Operating system: Darwin Kernel Version 22.3.0: Mon Jan 30 20:39:35 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T8103 22.3.0
Login status: logged in
Catalyst license: insider
Insider build toggle: on
Live preview: on
Legacy editor: off
Base theme: dark
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none

2 Likes

So your report got me trying something and by chance I had two tabs open side-by-side. In one note I changed the property type from the default text, as you also have in your screenshots for date and time, to time for my created and updated properties and I noticed it changed it for my other note as well.

It seems this property type association is interpreted as text by default and globally adjusted once you set it to a particular type constraint.

For me, using YYYY-MM-DD HH:mm:ss as created and updated does allow type change from text to time and back again without any problem. So I guess the current parsing requires the seconds to be present.

So I got playing some more and created a new Vault. By default there is no .obsidian/types.json. It knows of three properties internally, namely aliases as multitext, cssclasses as multitext, and tags as tags. When I added my new property created, it used multitext as default type. I added the value 2023-07-30 09:27 and changed it to time. Now .obsidian/types.json got written with created being defined as datetime.

Next I added an updated with 2023-07-30T09:27 and then changed it afterwards to time. It worked without a problem. And now .obsidian/types.json has an additional entry for updated with datetime.

I could also switch between time and date without problems because changing the property never touched the underlying YAML’s entry that had the datetime.

It seems the first setting of types for properties needs to be an explicit choice on the side of the user. I wonder if you set up the types first and then try the API calls, if everything just works as expected.

1 Like

I am facing the same problem. I have tried multiple times with brand-new vaults. I can create the different types of property types alright at first. However, after a while, all properties change back to the text type whenever I try to create new or modify old property types.

I have checked the JSON file in .obsidian folder. The types within the JSON file change correctly but those changes are not reflected within the Obsidian Vault i.e. the JSON file might say that the type is datetime but the Obsidian vault still has the property as text.

1 Like

I might make a stupid suggestion here but have you tried using lowercases instead of uppercases ?

I stumbled upon this earlier and solved it by using only lowercases in my keys :woman_shrugging:

1 Like

Damn, that fixed it. Thank you so much! Spent so much time today trying to understand it. It seemed a bit too visible to be a bug. Thanks again!

1 Like

My pleasure :smiling_face: !
Glad to know this also worked for you :grin: !

1 Like

I’m also running into this issue (on v1.4.1). Some of my dates have been given the “Text” type, some have been given the “Number” type, but none are recognised as dates. All are in the format YYYY-MM-DD. (In case it’s useful, these are fields named “Bought”, “Started”, “Finished”, which I use on book-related notes).

What’s particularly painful is that (as you describe above) I can’t change the types of these fields, but also I can’t save dates at all in new notes (presumably because they don’t match the incorrectly inferred type)!

My old notes seem to preserve the existing dates with a type warning, but when I try to add a date to a new note it is reset to “No value” when I reopen the note - the values are not saved. This is really worrying because Obsidian’s incorrect inferences about types is actively overriding my ability to write notes in the format I’ve been using, and I’m hesitant to edit any existing note in case I also lose the values from these existing fields.

This is the first time I’ve run into an Obsidian bug that seems actively obstructive (in that I can’t write these fields) / potentially destructive (in that I actually lose data that I’ve filled in when I reopen a note).

1 Like

Hi Nick. I would suggest starting a new thread for your problem so more people can see it. Also, have you tried editing the properties with restricted mode turned on? Not many plugins have been updated since the incorporation of properties.

Thanks for the suggestion Asterix - I’m not really using any community plugins, so I don’t think it’s plugin-related. I’m seeing the same issue regardless of whether I’m in restricted mode.

Hmm, I didn’t want to start a new thread, just because as far as I can tell I’m experiencing the exact same issue described at the top of this thread - I just wanted to add a few extra details (like, not being able to save data to fields in new notes). I might give it a few days and if this is still an issue I’ll open a separate thread. In the mean time I’m going to try downgrading from the insider build in the hope that I can at least avoid this issue for now.

1 Like

What can help in troubleshooting here is a screenshot of your properties view and the pasted output of .obsidian/types.json from your vault.

I am having this issue as well, worked ok for a couple of days
type file
Example 1

This should be fixed in 1.4.2

4 Likes

Took the catalyst route as a thankyou for this feature, then it broke, then you state it will be fixed.

Still thankful and thrilled with the whole Obsidian concept and execution.

Keep on going!

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