String to time format comparison [dd hh:mm:ss.mss]

I have a data table which has three columns EmpID, EmpName, TotalInTime as below:
EmpID EmpName TotalInTime
101 John N 02 05:20:45:356
202 Rachel K 00 00:45:23:123
322 Johny S 00 07:12:33:223

I wanted to get the records for all employees who stays in the office more than 5 hours (i.e. 00 05:00:00.000) and store in another data table.
Note: we can read “02 05:20:45:356” as “2 days 5 hours 20 mins 45 seconds and 356 milliseconds”

For that, I am looping data table using For Each Row.
But i have to read ‘TotalInTime’ value in String.
Now, My question is that how to convert it into required format and compare with my threshold value ‘00 05:00:00.000’?

Hi @gopal_1981
You can achieve this with substring instead of doing conversion.

“02 05:20:45:356”.Substring(3,2) → This gives the hours → Store in variable Hours
“02 05:20:45:356”.Substring(0,2) → this gives the days → store in variable days

if( hours>=05 OR days > 0 )
this means, employee has worked for more than five hours

please mark as solution if this solved your issue.



Thanks for reply. Seems it will work. However, here we need to convert ‘Hours’ string variable into Int16 for ‘If’ condition, right?
I will try it and update you. Thanks!

CInt(StringVariable) – converts to integer.

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