In Java
I want to use Localtime as a condition 3 IF statements
For example
If time<=12 print good morning
If time<=17. Print good afternoon
If time <=20 print good evening
Else print good night
In Java
I want to use Localtime as a condition 3 IF statements
For example
If time<=12 print good morning
If time<=17. Print good afternoon
If time <=20 print good evening
Else print good night
We can model it within UiPath with the help of

But also have alternates
Use the Else If condition activity,
- If -> DateTime.Now.Hour <= 12
Print Good Morning
- ElseIf -> DateTime.Now.Hour <= 17 andalso DateTime.Now.Hour > 12
Print Good Afternoon
- ElseIf - DateTime.Now.Hour <=20 andalso DateTime.Now.Hour > 17
Print Good Night
Or
You can do it with one assign activity by using below expression,
- Assign -> Output = If(Datetime.Now.Hour<=12 AndAlso DateTime.Now.Hour>17,"Good Morning",If(DateTime.Now.Hour<=17 andalso DateTime.Now.Hour>12,"Good Afternoon",If(DateTime.Now.Hour<=20 andalso DateTime.Now.Hour>17,"Good Night","")))
Check the below image for better understanding,
Hope it helps!!
Hi @216O9_Shagun ,
if you want in single assign activity check this.
Code:
If(CInt(Now.ToString("HH"))<=12,
"Good Morning",
If(CInt(Now.ToString("HH"))<=17,
"Good Afternoon",
If(CInt(Now.ToString("HH"))<=20,
"Good Night",
"")))
st(String)

Thanks,
lets assume a dictionary of:
New Dictionary(Of String, TimeSpan) From {
{"Good Morning", New TimeSpan(0,0,0)},
{"Good Afternoon", New TimeSpan(12,0,0)},
{"Good Evening", New TimeSpan(17,0,0)},
{"Good Night", New TimeSpan(20,0,0)}
}

and a Variable of TimeSpan - myLocalTime
We can do:
Tests:
And
And
And