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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Need to calculate Age based on installation date/birthdate

(0) ShareShare
ReportReport
Posted on by 836

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?

I have the same question (0)
  • Suggested answer
    Beshoy M. Nagib Profile Picture
    10 on at

    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

  • Suggested answer
    Community Member Profile Picture
    on at

    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.

  • Ravi Fulani Profile Picture
    836 on at

    Will calculated filed will get refresh automatically  each day

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    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

  • Beshoy M. Nagib Profile Picture
    10 on at

    Hi Bipin,

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

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 45 Most Valuable Professional

#2
iampranjal Profile Picture

iampranjal 36

#3
Satyam Prakash Profile Picture

Satyam Prakash 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans