Hi,
Before my questions, just two notes: 1) I’m a relative newbie in Obsidian and an absolute newbie in Dataview plugin; 2) I’m not a programmer or similar and my knowledge of code is almost zero.
Having said that (just to excuse my ignorance), I start with the compliment: this plugin seems a huge tool to build great databases, with potential to definitively replace one of the main features that retains some users in Notion.
Now my case. For research purposes, I intend to create a database with some historical facts (a kind of complete biography of a historian). For this, for each ‘historical fact’ I create a .md file with some notes, information and links (files indexed in Devonthink and using the advantages of Devonthink’s x-callback-url to create links between different files/formats).
Now, with the ‘dataview’, I intend to use this tool to create a kind of landing page that serves simultaneously as a ‘timeline’ (creating a table, ordered chronologically, with the information of the fields introduced in the YAML metadata).
Obviously, one of the main fields concerns dates. And my problems / limitations start here.
Here is my query:
```dataview
table (dataInicio.year + "/" + dataInicio.month) as Inicio, (dataFim.year + "/" + dataFim.month) as Fim, ((dataInicio - date(1933-11-03)).year + "/" + (dataFim - date(1933-11-03)).year) as Idade, grupo, subGrupo as sub-grupo, subEventos as sub-eventos, file.tags as tags, link
where file.name != this.file.name
sort dataInicio
My problems are related to these three fields (sorry for portuguese language) : dataInicio (Startdate); dataFim (Enddate); Idade (age).
- The first issue is related to the date format: whichever format is used in the metadata fields (YYYY-MM or YYYY-MM-DD), the table shows the format
day of the week, day/month/year. The historical facts have very different dates: precise dates (YYYY-MM-DD), others less (YYYY-MM) and others very vague (YYYY - in these cases I have to deduct one month). The day of the week information is totally unnecessary for this type of database. To remove this information I use the code (dataInicio.year + "/" + dataInicio.month) to get something like 1953/10. If I add dataInicio.day I have a problem: in the ‘historical facts’ with the format YYYY-MM, the result add the first day of the month (YYYY-MM-1).
- With the previous solution, if the
dataFim (endDate) field is empty, the table presents the result “null/null” and not the “-” as defined in dataview settings for nulls results. [All the ‘historical facts’ have a start date (more or less accurate) but some have not end date.]
- The field
Idade (age) is intended to show the age of the historian at the beginning and ending (if applied) of each ‘historical fact’. For that I use this: ((dataInicio - date(1933-11-03)).year + "/" + (dataFim - date(1933-11-03)).year) as Idade (for results as “23/32”). When I have both dates (start and end) everything works correctly, but if the end date is empty the result is “null/null” (does not even display the first value, related to age at the start date). The only way to formula works seems to be the introducing of an end date equal to the start date!
Well, that’s enough for now. Does anyone have any suggestions for overcoming these limitations or for now these limitations are intrinsic to the plugin?
Thanks.
One suggestion: considering the idea of a ‘timeline’, it would be truly incredible if there was a possibility to extend this plugin - using the results of the query - to build a mermaid gantt diagram.