Calculate Age from Date of Birth in Pega

Pega provides an easier way to implement the age calculation from our respective DOB property. Have You ever tried to apply in your real time scenario. Here We Explore , How to implement this,

This article illustrates how to calculate age from DOB property .

Example Scenario :

ABC company uses the pega platform to calculate age from Date of Birth . Let’s have a look at how pega performs it .

Configuration:

Step 1 :

Create a case type (Eg: Sample) and provide a stage name as “New Request”. Add a collect info step name it as “Provide Detail”.  Hurray! We are done designing our case life cycle.

Step 2 :

Create property called   “Date of Birth”  as date  time type and property called “Age” as integer type with read only option . create the necessary fields as shown below.

Step 3 :

Now it’s time to configure the topic of the day . Create Declare expression for age property .

Why Declare Expression ? 

Declare expression comes under the decision category and can be used to compute a value based on the expressions we create. For example , we are going to compute the value of age property based on our custom expression . 

Step 4 :

Once you click the gear icon , it will forward you to the express builder screen as shown below.         Add the below expression to calculate the age 

            @round(@DateTimeDifference(.DateOfBirth+”T000000.000 GMT”,@CurrentDateTime(), “Y”)) + 1

@DateTimeDifference – It computes the time difference between two Date Time String and returns the difference as double value corresponding to the specified precision. 

@round  – It returns a value equal to ‘numericArg’ rounded to the nearest integer value .

Here , we are calculating the difference between the current date and date of birth property and round it to the nearest integer value to get the exact age .

Step 5 :

Hey Techies, Let us also learn the new thing in our date control . Usually pega by default provide you the date and calendar control only for the past 10 years . To add more years to our calendar property , open your respective section as shown below .

Step 6 :

Open the respective cell property of calendar control . And under the display range , add previous year and next year as per your convenience . Here I added 100 years as display range.

 Hurray!!! The implementation part is done!!! Let’s run and check it.

Step 7 :

 Run the Age Calculation case type and enter the date of birth. So age will be displayed as read only format .click submit.

Youtube Video:

1 Comment

Add yours →

  1. How to Calculate the Age in Below Format?

    Ex: 20 Years 8 Months 10 days

© 2024 Pega Tech

Theme by Anders NorénUp ↑

error: Content is protected !!