Calculate Age from Date of Birth in DHIS2


Hello
As shown above, I have a event form where I register participant information.
Now I want Age to be calculated from Date of birth field and directly put below the data of birth field. How do I do it ??

Thank you @Eyuel_Nigussie for posting.

You can simply do this by using program rules. You can use the function d2:yearsBetween which will produce the number of years between the date of birth and the current date.

Here is a quick explanation about the d2:yearsBetween function:

You can read more in the documentation:

You can also check similar examples in DHIS2 PLAY (https://play.dhis2.org/)

3 Likes

Hi @Eyuel_Nigussie you will need to create another attribute to have age as calculated value from date of birth as indicated by @hanin.saadah Hanin

2 Likes

Thanks @mutali by attribute you mean data element right?

@Eyuel_Nigussie

It actually depends on the place of the field. If it’s in the registration page so it’s a Tracked Entity Attribute. If it’s inside the stage so it’ll be a Data Element.

Is the posted picture above from Tracker stage or the registration page?

1 Like

@hanin.saadah Apologies for the late response>

Yes indeed it is in the event tracker stage’s form.

1 Like