MISC Custom Fields: Calculate person's age

Hi! i'm using JIRA 6.3.9

 

I have date of birth, and i need JIRA to count his age.

I tryed this formula:

<!-- @@Formula: issue.get("created")==null ? null : ((new Date().getTime()) - issue.get("customfield_xxxxx").getTime()) / 1000 / 31536000 -->

It works close, but not perfect. If i put date of birth 20 december 1974 - it will count 40 years (instead of 39)

1 answer

1 accepted

That's because the value is rounded up to the nearest integer. If you want to truncate the value instead, use Math.floor( ):

&lt;!-- @@Formula: issue.get("created")==null ? null : Math.floor(((new Date().getTime()) - issue.get("customfield_xxxxx").getTime()) / 1000.0 / 31536000) --&gt;

still 40 years. I think thats because it don't count 29 february every 4 years

Yes, you should divide by 31557600 (365,25 days per year).

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

800 views 2 19
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you