HI,
Bit new to CRM Could you kindly Advice how to Calculate Age in below format(in Years, Moths and Days). I Could not find any Info on this in any forums.
Regards
Ja
HI,
Bit new to CRM Could you kindly Advice how to Calculate Age in below format(in Years, Moths and Days). I Could not find any Info on this in any forums.
Regards
Ja
Thank you for this Asmaa
Thanks
Hello Jag, i tried to make it clearer
HI Asmaa,
Thank you I did download and tried importing and getting below error
the below expressions you mentioned where do they go.
1. sub(int(formatDateTime(utcNow(), 'yyyy')), int(formatDateTime(items('Apply_to_each')?['birthdate'], 'yyyy'))) //to abstract today year and Bod year
2. sub(int(formatDateTime(utcNow(), 'mm')), int(formatDateTime(items('Apply_to_each')?['birthdate'], 'MM'))) //to abstract today month and Bod month
3. sub(int(formatDateTime(utcNow(), 'dd')), int(formatDateTime(items('Apply_to_each')?['birthdate'], 'dd'))) //to abstract today day and Bod day
4. add(12,sub(int(formatDateTime(utcNow(), 'mm')), int(formatDateTime(items('Apply_to_each')?['birthdate'], 'mm'))))
5. add(31,sub(int(formatDateTime(utcNow(), 'dd')), int(formatDateTime(items('Apply_to_each')?['birthdate'], 'dd'))))
at the end add an update row to update the Age field
Thanks
Jag
i exported solution and put it in this link, try to install it in you environment
Hello,
I do have with me but i'm not sure how can i share it with you i tried to describe the way i did it and add the expressions and algorithm to achieve this
Hi Asmaa,
Thank you for the Reply, this is amazing, if you dont mind me asking do you have a solution for this.
Thanks
Jag
Hi Ja,
You can create a custom field whose type is a calculated field to calculate the age.
1.Make your DOB field behavior is not date only, otherwise, you can’t use Diffyear function with Now() and birdthdate.
2.For original age field, you can’t change its field type, so you need new another age field (field type is calculated).
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.
2.Add ‘condition’ step.
3.In Yes branch:
(1) Add ‘compose’ step.
(2) Add ‘Update a record’ step.
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.
Hello,
Since you are trying to calculate the age, then this action will be done daily, then i command you to use a Schedule Flow,
I have created a text field and called it Diff Date where i will store the age as you described,
then i have created a flow as follow :
First initialize you variable
Age Year, Age Month and Age Day stays empty until we fill them later on
Now Year = int(formatDateTime(utcNow(), 'yyyy'))
Now Month = int(formatDateTime(utcNow(), 'mm'))
Now Day = int(formatDateTime(utcNow(), 'dd'))
add a list row action and apply the following algorithm
if (monthNow >= monthDob)
var monthAge = monthNow - monthDob;
else {
yearAge--;
var monthAge = 12 + monthNow -monthDob;
}
if (dateNow >= dateDob)
var dateAge = dateNow - dateDob;
else {
monthAge--;
var dateAge = 31 + dateNow - dateDob;
if (monthAge < 0) {
monthAge = 11;
yearAge--;
}
}
Please mark my answer as resolved if you find this helpful
André Arnaud de Cal... 291,703 Super User 2024 Season 2
Martin Dráb 230,433 Most Valuable Professional
nmaenpaa 101,156