Can MomentJS be used fully in Obsidian Notes yaml?

389 views Asked by At

According to MomentJS documentation, it is possible to capture "BC" dates: https://momentjs.com/docs/#/customization/eras/

However, Obsidian Notes can only seem to recognise them as negative numbers/strings. I know Obsidian supposedly fully supports javascript so can anyone provide guidance on to how to "unlock" this functionality please?

My goal is to capture historical dates (both AD and BC) in the files' YML frontmatter that I can then query in dataview like this:

```dataview
TABLE without ID
 file.link as People, dob AS "Date"
FROM "People"
WHERE dob
SORT dob desc```

From what I've read, the dates need to be in ISO format - and Wikipedia implies that it should be possible just by prefixing with a -. However this doesn't seem to work as I have tried variations of the below in my frontmatter (I'm using Christmas day as dummy month and day) with no success:

---
dob: -427-12-25
---
---
dob: -000427-12-25
---

The closest I felt to a solution was from the following link that talks of defining "eras" in momentJS but I don't see an easy way to do this in Obsidian (and I don't want to introduce potential issues in the future): https://momentjs.com/docs/#/customization/eras/

UPDATE: Below is a screenshot of the "error" I get in my Dataview table. Additionally, if I use dob.year AS "Date" in my dataview query then the Socrates and Plato rows disappear from the results: Dataview query result

0

There are 0 answers