Comparing two strings and checking greater than 1hr

I m having to string vaules

Str_starttime = 02: 00pm
Str_endtime = 05:00pm

I need to check
The difference between this 2 variables is greater than or equal to 1hr

Str_starttime - Str_endtime > = 1hr

In general we want to do it on Timespan base. The PM/AM Marker we can better handle with DateTime conversion options (CDate, Convert.ToDateTime, Datetime.ParseExact). With TImeOfDay we get the Time part and will use it for the check

grafik

Strongly recommend you parse them into datetimes and use the .NET libraries to check the difference (use a System.TimeSpan variable for the difference).

E.g. use something like this DateTime.TryParse Method (System) | Microsoft Learn

and then something like this

Dim diff1 As System.TimeSpan
' diff1 gets 185 days, 14 hours, and 47 minutes.
diff1 = date2.Subtract(date1)

But in UiPath you’d use the assign activity instead of writing it out in code

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.