How do you spell a condition to find the correct age?
I want the age to correspond to 26 years because I have 1996 as an attribute in the structure
Hi Sabrina,
check this post, you'll get the expression to calculate:
https://www.outsystems.com/forums/discussion/35960/calculate-age-current-date-birth-date-age-years/
Regards
i need an if condition to calculate age
The condition is full of IFs:
If(Month(CurrDate())
Year(CurrDate()) - Year(BirthDate) - 1,
If(Month(BirthDate)=Month(CurrDate()) and Day(CurrDate())
Year(CurrDate()) - Year(BirthDate)))
Good formula! It should do the trick easily
Hi Sabrino,
You can use the year different by using the inbuilt action in Outsystems.
Year(CurrDate()) - Year("Yourdate").
if you want the date in human readable format the you can use FormatDate() Action.
you can also use pretty date format component available on forge.
Hope this helps,
Regards,
Shoeb
This will assume the person's birthday already happened this year.
Help
I already wrote the formula needed to calculate the exact age.
Hi All,
In that post Jose is pointing to, I'd like to direct attention to the answer that came 2 years later, from Afonso Seralha. (At least if age is wanted in terms of how many birthdays have passed.)
Age = Year(TestDate)- Year(Birthdate) -
If(Month(TestDate)*100+Day(TestDate)<Month(Birthdate)*100+Day(Birthdate),1,0)
Dorine
PS @José Gonçalves : i notice that when I paste text in this forum, it cuts off everything after a < sign that isn't surrounded by spaces, I suspect that also happened to your answer.
Alternatively,
If you are not interested in the age itself, but just want to check if somebody has reached a treshold age of let's say 21,
I guess you can just have the condition :
AddYears(BirthDate,21) <= CurrDate()
Hello
You can also simply write a JavaScript program to calculate Age
You can write it in a client action and make it as a function and you can reuse it anywhere, it will return you Age
You can check demo Sample here -
https://personal-wwkmlamd.outsystemscloud.com/AgeCalculator/CAlculateAge?_ts=638008671306924614
you can also refer to other solution in above comments
I have attach Oml for reference
I hope this helps
Best Regards
Tousif Khan
Hi @Tousif Khan ,
this will be upping the age 1 day too early on some occasions involving leap years.
Can't really explain it, but you can try by adjusting your app to take in a second date instead of using CurrDate(), and then test with for example age on 31/12/2021 for someone born on 01/01/2020. It should still be 1, but it is already 2. On 31/12/2025 it should still be 5, but it is 6.
also, doing it in Javascript limits the applicability to client side.
Hi @Sabrina Avolio
I know I might be a little late, but you can use the following logic:
(TextToInteger(FormatDateTime(CurrDate(),"yyyyMMdd")) - TextToInteger(FormatDateTime(Birthdate,"yyyyMMdd"))) / 10000
Husain