Calculated Fields Bundle - DATEDIF

Anyone have experience using the Calculated Fields Bundle (https://www.npmjs.com/package/@directus-labs/calculated-fields-bundle) I am trying to use it to calculate the age of an item based on a field. Any help would be appreciated.

2 Answers

2

I tried this but it doesn’t seem to work:

DATEDIF(Date of Birth, NOW(), “Y”)

So it does work while editing an existing item but where I need it is in the table layout... Thoughts?

–

Hello Tony, could you please explain how it works? suppose i have the dob field and in that I am storing the date of birth now I want to show the age in number so how can I do that using the abve package? Do I have to create another field for it or like how?

–

Hi @tonypiazza,

don’t know if this is still relevant or if you figured it out in the meantime. But better late then never:

I tried the formula you suggested in your own answer and it seems to work without an problem on my end.

Formula setup:

Working calculation:

A couple of ideas what might be different between our setups:

  • For this example I used the “Date” field type which only stores “YYYY-MM-DD”. I’ve also tried it with DateTime, which also works. If you are still interested maybe you could share your field setup?