Calculate Age with UI only field

  • 2
  • Question
  • Updated 1 year ago
  • Answered
I'm trying to calculate age based on today minus date of birth in a UI only field but I'm not having luck getting the correct result I do get a result, but it is huge. I have tried assuming graduations of days, hours, minutes, and even seconds, but the number is still way too large. Anyone have ideas of how I would formulate this in UI only?
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb

Posted 3 years ago

  • 2
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Javascript calculates dates in milliseconds... 
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
ah... thanks....
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Just thought I'd post the formula to calculate someones current age based on their birth date.
FLOOR((TODAY() - {{BirthDate__c}})/ (365*3600 * 24 * 1000))
(Edited)
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Thanks for posting this Bill. 
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Hey guys. We probably don't want the official response for this question to be "ah... thanks...."
;)
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Good catch Matt!
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
It was a well crafted response ;)
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
Our community doesn't allow a comment to be official. Only replies. Thus, ah... thanks.... became official because Bill's comment was below it.
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
The Officially correct answer to calculate someones current age based on their birth date is:

FLOOR((TODAY() - {{BirthDate__c}})/ (365*3600 * 24 * 1000))

I take full credit. I would never think to say it is Bill McCullough who is the Skuid Wizard. I am the Walrus. Coo Coo CaChoo.