Format of duration function in Dataview table

First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.

What I’m trying to do

Format the output in a Dataview table so that it shows the tenure of a colleague in Years, Months and Days (but excludes minutes, seconds and milliseconds).

Things I have tried

I have a note for each colleague where contains(notetype,"people). This ‘people’ note includes roles, area-of-work, joined (as date), etc. as inline metadata.

Then I have created a note for my department and I have created the following dataview table. This produces a list of colleagues, including their tenure (which is the duration between when they joined and the current date).

TABLE without ID AS Name, Joined, date(now) - joined AS "Tenure", role AS Roles, module AS Modules
WHERE contains(notetype,"people")
WHERE contains(this.file.inlinks,
WHERE left = false

Tenure works but provides minutes, seconds and miliseconds, as shown in this screenshot.


I have tried looking at the Dataview Git pages and this forum. I have also looked at luxon formating but cannot understand how to use this in the table query.

Using date(now) gives you the time portion of just now as well as the date, so maybe it’s good enough for you to use date(today) which will only give you the date portion of today.

Other than that, you can start messing around with various other functions, but by far its easier to just dates when calculating duration in days. (Another useful function can be striptime() which removes the time portion of a date and time variable)

Hi holroy,

Thanks so much for the swift response. `date(today0’ works fine.

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