i have a variable [ Dim mytime = “12:30:00 AM” ]
i want to subtract mytime from TimeOfDay and i also want to get the difference as a integer value… how should i do that..
i have added the following code
Dim mytime = DateTime.Parse("1:16:00 AM")
Dim result = TimeOfDay - mytime
dim finalresult = result.Seconds
but it is giving me negative values
Easy:
First, convert the
myTimeto aDateTime– either directly:Or by parsing a string:
But you won’t get an integer – how should this work? What should the integer represent? Instead, you get a
TimeSpan.If you need to have the difference in seconds, you can extract that, of course:
Same goes for minutes or any other component.