Jump to content
  • 0

Get Exact Age


JanineB

Question

How can I get the exact age:

Ex: Today's date is Feb 4, 2019. My birthday is Feb 5, 1998. On my Calculated Value, it shows 21 years old already. My question is how can I show it as 20 years old because it is still not Feb 5. 

This is my current Formula:    Datediff(day,[@Date_of_birth],GetUTCDate())/365

 

I wanted it to be based by day. 

 

Appreciate your help!

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 1

Hi @JanineB,

 

You may try this formula as well. 

 

FLOOR(DATEDIFF(YEAR,[@field:Date_of_Birth],GetDate()) - 

(CASE WHEN DATEADD(YEAR,DATEDIFF(YEAR,[@field:Date_of_Birth],GetDate()),

[@field:Date_of_Birth]) > GetDate() 

THEN 1 

ELSE 0 

END ))

 

It worked in almost all scenarios, considering leap year, date as 29 Feb, etc.

Hope this helps.

 

-kristina

Link to comment
Share on other sites

  • 0

I tried the solutions provide by @DefinitelyNot31337 and @Hastur and it gives me the wrong age (I tried July 13 1999 and it outputs 23 when it should be 22) so I created my own.

CASE
WHEN DatePart(m, [@field:birthday]) > DatePart(m, SysUTCDateTime()) AND (DatePart(d, [@field:birthday]) != DatePart(d, SysUTCDateTime()))
THEN DateDiff(year,[@field:birthday],SysUTCDateTime()) -1
ELSE DateDiff(year,[@field:birthday],SysUTCDateTime())
END

Hope this helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...