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, loom, loom for training, loom for teaching, video training, async learning, online education, screen recording, loom tutorials, loom use cases, atlassian learning, team training tools, instructional video, virtual training tools

🛗 Elevate Your Training and Enablement with Loom

Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!

Register today
AUG Leaders

Atlassian Community Events