web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to simply get age with calculated field

(0) ShareShare
ReportReport
Posted on by

Hello,

I'm very disappointing by Dynamics, some simple thing is not possible without complicated workaround for example I just want get contact Age from calculated field on this entity.

Unfortunately I'm unable use Diffyear with Now() and birdthdate :

DIFFINYEARS(birthdate,NOW()) -> not compatible fields

But

DIFFINYEARS(birthdate,birthdate) -> compatible

DIFFINYEARS(NOW(),NOW()) -> compatible


That very strange isn't it ?

Is there a simple way to do that ?

Thanks,

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at
    RE: How to simply get age with calculated field

    If you choose the DIFFINYEARS approach you need in total four custom fields:

    custom field birthday_custom (Date and Time) with business rule to write the value of oob field birthday into the custom field --> is needed because you cannot use date functions on the oob field

    calculated field today with formula Now() --> is needed because you cannot use functions in conditions if using calculated values

    calculated field next_birthday with formula AddMonths(DiffInYears(birthday_custom, Now()) * 12, birthday_custom)

    calculated field field age with formulas:

    if next_birthday greater than today

    DiffInYears(new_geburtstagcustom, new_nextbirthday) - 1

    else

    DiffInYears(new_geburtstagcustom, new_nextbirthday) 

  • RugerSR762 Profile Picture
    375 on at
    RE: How to simply get age with calculated field

    Any ideas as to why the DIFFINYEARS function only looks at the year but not the actual date?  For instance we enter DOB 7/1/2000 and it should return 19 as that is the current age.  However, it is returning 20.  The same holds true for any date entered (also ran it all they way up through 12/31/2000 and getting 20 as the calculated result). Is there a different, non code solution or would JS be a better approach?

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: How to simply get age with calculated field

    Birthdate being the system field, it is not available to change the behaviour/format so you have to create  new field with the datetime behaviour in order to use the calculated field functionality. If you still want to use out of box birthday field then you can create a business rule (entity level) to copy the birthday value to your custom dDOB field and then hide that field.

    This way, user will set the birthdate on birthday field, which will be copied to custom DOB field and the then the age is calculated from your custom DOB field.

    birthday.png

    Hope this helps.

  • Community Member Profile Picture
    on at
    RE: How to simply get age with calculated field

    Thank for your reply,

    But realy I must create a custom field to calculate that ? That's ridiculous.....

    Even is easier in excel to calcultate it

    Is there not a possibility to caste birthdate field ?

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: How to simply get age with calculated field

    Hi,

    This is because NOW() is a date time so you have to make your DOB field format as Datetime in that case instead if date only format. I understand its look odd DOB with time , you can set time with 00 using JS .  Here I did  have a look below screenshot -

    2019_2D00_05_2D00_01_5F00_1_2D00_05_2D00_55.png

    2019_2D00_05_2D00_01_5F00_1_2D00_05_2D00_55.png

    Here is the result -

    2019_2D00_05_2D00_01_5F00_1_2D00_07_2D00_09.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans