How to add and minus minutes in from time

I am storing start time in string variable and after that i am calculating some time difference which is stored in generic value variable.

I want to calculate final start time which is Start time - time difference

Doing same thing for End time also where i am adding End time + time difference.


Can you share specific example (input and expected output)?

Basically we can achieve it toconvert it to DateTime type then add or subtract minutes, finally convert it String.


ok Example is
I am getting some time which is start time from web its in HH:MM which i am storing inn string variable and after that i have to calculate some time difference which is based on some calculation and that i am storing in Generic variable. Now i have to calculate the time which is like
Start Time - Time Difference let say start time is 03:12 and time difference is 54
3:12-54 = 2.58


The above result should be 2:18, shouldn’t it?
Can you try the following expression?

TimeSpan.ParseExact("3:12","h\:m",System.Globalization.CultureInfo.InvariantCulture).Subtract(New TimeSpan(0,54,0)).ToString("h\:m")


1 Like

Thanks sir. Getting below issue.


Can you check content of StrartTime at Locals panel when error occurs? If there might be extra whitespace, cany you try StartTime.Trim in the expression?


Assign: Cannot convert Generic Value to System.Int32

is it like should i convert timedifference which is generic value to int 32 using cInt

Yes, we can convert it to int32 using CInt(genericValueVar) or CInt(genericValueVar.ToString)


Still struggling
I had check the start time is in string and having value and time difference is Generic value variable and also having value i had trimmed both the value but still getting issue.


How about the following expression if your genericValue has “01:00:00” style string?



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