Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

MISC Custom Fields: Calculate person's age

Stas December 17, 2014

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

0 votes
Answer accepted
David _old account_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 18, 2014

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;
Stas December 18, 2014

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

David _old account_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 18, 2014

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

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events