Discussion

Want to calculate Age from DOB

Hi.. According to my req, I have to calculate Candidate Age from DOB. I used DateTimeDifference(), but getting garbage value.. Help me in this context..

Comments

Keep up to date on this post and subscribe to comments

March 7, 2012 - 3:38pm

You can use this declare expression @toInt(@substring(@CurrentDateTime(), 0, 4))-@toInt(@substring(.DateOfBirth, 0, 4))

March 7, 2012 - 4:04pm

@DateTimeDifference(.DOB,@CurrentDateTime(),"Y") will return a double of the number of years difference between the two dates. So 1.5 would refer to a person one year and 6 months old.

March 8, 2012 - 12:59am

ThanQ very much ARJUNLATH and AMMOR for ur response.. :)

March 8, 2012 - 1:46pm

using ARJUNLATH's answer could give errors since it does not calculate months or days ( would not account for any birthdays until dec 31)

@toInt(@substring(@CurrentDateTime(), 0, 4)) - @toInt(@substring(.DateOfBirth, 0, 4))

This one is acurate:
@DateTimeDifference(.DOB,@CurrentDateTime(),"Y")

then use the decimal on the answer to caluculate months or days if you need them. (months: (ans decimal) * 12)

May 31, 2016 - 5:39am
Response to ARJUNLATH

Thanks a lot.. really helped
 

November 20, 2013 - 11:22pm

Thank You,.it worked perfectly:)

March 6, 2014 - 1:24pm

Where do you put the @DateTimeDifference(.DOB,@CurrentDateTime(),"Y") in the system?

 I'm working with Pega 7 I put in the system under declare expression:

 

Set Age = Valyue of @DateTimeDifference(.DOB,@CurrentDateTime(),"Y")

 

 

May 14, 2015 - 5:14am

In Pega 7, use data transform / declare expression and set the age value as

@(Pega-RULES:ExpressionEvaluators).round(@(Pega-RULES:DateTime).DateTimeDifference(.DateOfBirth+"T000000.000 GMT",@(Pega-RULES:DateTime).CurrentDateTime(), "Y")) +1

 

This is other way to calculate age.

March 17, 2016 - 5:31am

Thank you ShaliniPartha..

 

It worked perfectly.

 

 

July 28, 2016 - 12:12pm

I used above rule in data transform.but it is displaying only years not months and days..How can get detailed age

Mod
July 29, 2016 - 3:55am
Response to SateeshG5647

Hi Sateesh,

Thanks for posting your question here in the PDN forums. Not sure if you're aware but we have a new Product Support Community that just went live! I would like to invite you to post your question there. That will be the best place moving forward for you to receive assistance.

I'll be closing this thread now to future replies.

For your Pega Product related question, please post in our Product Support Community. That is the best place for you to receive assistance.

Hope to see you there!
Lochan  |  Community Moderator  |  Pegasystems Inc.

Lochana | Community Moderator | Pegasystems Inc.