Hi team,
I am working on acme UiPath test where in I need to display the employee age older than 35.
I have used the condition in if activity
Cint(Now.Tostring(“yyyy”))-Cint(dateofbirth.Split("/"c).Last())<35
And date of birth is the output of get text …
When I run it’s nt displaying anything it’s just executing successful without any error.
Can u plz help.me.with this.
Yoichi
(Yoichi)
October 20, 2023, 8:25am
3
Hi,
For now, can you try the following expression?
Cint(Now.Tostring("yyyy"))-CInt(System.Text.RegularExpressions.Regex.Match(dateofbirth,"\d{4}").Value)
Regards,
ppr
(Peter Preuss)
October 20, 2023, 8:27am
4
Lets do it step by step:
When we do have strings, we would parse it into a datetime e.g.
Person is borned in Novemeber
So a year only calculation will bring a wrong result as 2023 - 2002 = 21
But the Person is still awaiting the birthday and today (10/20/2023) the age is 20
So we can do:
now.Year - Dob.Year - Convert.ToInt32(now.date < new DateTime(now.Year, Dob.Month, Dob.Day))
And the condition looks like:
@Bhagyashree_S
try this once
outputstr=inputstr.ReplaceLineEndings(“”).split({“Birthdate”,“Email:”},StringSplitOptions.none)(1).Trim.split(“/”).Last
gives you the output as 1952
use assign activity and pass the below code
outputyear=Cint(Now.tostring(“yyyy”))-cint(outputstr)
later use it if condition
outputyear<35
Hi @Bhagyashree_S
Please find the below Solution.
AgeDetect.xaml (7.5 KB)
It’s showing as replacelineendings is not a member of string
It’s says document is invalid
lrtetala
(Lakshman Reddy)
October 20, 2023, 9:07am
9
Hi @Bhagyashree_S
Try this
CInt(Now.ToString("yyyy")) - CInt(dateofbirth.Split("/"c)(2)) > 35
or
CInt(DateTime.Now.ToString("yyyy")) - CInt(dateofbirth.Split("/"c)(2)) > 35
Hope this helps!!
For first code if have to display employees names along with age older than 35 …if I give < 35 then it’s not displaying anything.
Output of dateofbirth in gettect activity is 5/25/1993.
Here i have to display the employee age one by one which are older than 35.the dates are dynamic
Here i have to loop through all the employee names and get the details of age according to condition older than 35
system
(system)
Closed
October 26, 2023, 1:55pm
14
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.