• 0

# Get Exact Age

## 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.

## Recommended Posts

• 1

Hi @JanineB,

You may try this formula as well.

FLOOR(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

##### Share on other sites

• 0
```DateDiff(year, [@field:Birthday], '[@cbTimestamp*]') -

CASE WHEN '[@cbTimestamp*]' >
year,
DateDiff(year, [@field:Birthday], '[@cbTimestamp*]'),
[@field:Birthday]
) THEN 1
ELSE 0
END```

Hi  @JanineB, here's a syntax that definitely works.
##### Share on other sites

• 0

@JanineB
Hi!
Here is the up to date formula considering new Timestamp function:

```DateDiff(year, [@field:Date], SysUTCDateTime()) -
CASE WHEN SysUTCDateTime() >
year,
DateDiff(year, [@field:Date], SysUTCDateTime()),
[@field:Date]
) THEN 1
ELSE 0
END```

##### Share on other sites

• 0

You might want to also check this post for alternative ways to calculate age:

##### 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.

##### Share on other sites

• 0

Hi - Just an update on this, you may also use these formulas to know the exact age by day:

`DATEDIFF(hour,[@field:Birthday],SysDateTime())/8766`

`FLOOR(DATEDIFF(DAY, [@field:Birthday], SysDateTime()) / 365.25)`

## 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.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.