Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Need to calculate Age based on installation date/birthdate

(0) ShareShare
ReportReport
Posted on by 814

Hi There,

i can calculate age base on date of birth, via javascript, i found another method that is using calculated field. But my problem is javascript work on form load or form save or  field change. But consider I see the data in view which is 4 year old, and from past four years i never touched the records so in view i will be seeing wrong age. because that age which is present on record was calculated 4 years ago. 

Even if i try calculated field then also  I won't get data calculated for each record today. Any ideas what should i do?

  • Beshoy M. Nagib Profile Picture
    Beshoy M. Nagib 10 on at
    RE: Need to calculate Age based on installation date/birthdate

    Hi Bipin,

    Calculated fields are virtual and not stored at the database level, so they are gonna calculated correctly as well on the views.

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Need to calculate Age based on installation date/birthdate

    Hi,

    Calculated field only update the data onsave of the record.

    Please see below article.

    www.crmconsultants.co.uk/.../

    You can create Schedule based Power Automate to trigger your flow every day.

    docs.microsoft.com/.../run-scheduled-tasks

    Please mark my answer verified if i were helpful

  • Ravi Fulani Profile Picture
    Ravi Fulani 814 on at
    RE: Need to calculate Age based on installation date/birthdate

    Will calculated filed will get refresh automatically  each day

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Need to calculate Age based on installation date/birthdate

    Hi Ravi,

    I have tested with calculated field, it can get data calculated for each record today.

    1.Make your DOB field behavior is not date only, otherwise, you can’t use Diffyear function with Now() and birdthdate.

    pastedimage1603077664669v1.png

    2.For original age field, you can’t change its field type, so you need new another age field (field type is calculated).

    pastedimage1603077713763v2.png

    3.When all is set and publish all, you can refresh page, then calculated field will show correct age directly.

    Also, you can use Flow to update age, which don’t need create another field.

    1.Go Power Apps(https://make.powerapps.com/ ) to create an instant flow.

    pastedimage1603085575219v1.png

    2.Add ‘condition’ step.

    pastedimage1603085743696v2.png

    3.In Yes branch:

    (1) Add ‘compose’ step.

    pastedimage1603085877044v3.png

    (2) Add ‘Update a record’ step.

    pastedimage1603086471499v4.png

    split(string(div(div(sub(ticks(utcNow()),ticks(outputs('Compose'))),864000000000),365.25)),'.')[0]

    4.Save and test.

    In the view, select records you need and expand flow to click the flow just created.

    Then wait for several minutes and refresh page, the age will be changed.

    pastedimage1603086830594v5.png

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Suggested answer
    Beshoy M. Nagib Profile Picture
    Beshoy M. Nagib 10 on at
    RE: Need to calculate Age based on installation date/birthdate

    I believe calculated field will be the best solution for your case, you can use the below formula. The values on the calculated fields are calculated in the retrieve event thus, it will be reflected correctly on the view(s).

    clip_5F00_image004.jpg

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans