I'm running an application in which I'm able to obtain the required times, however when I try to deduct one value from another it comes up with error message stating conversion from date type cannot happen to timespan. The variables I use are shown below:
Dim downtime As TimeSpan
Dim uptime As TimeSpan
Dim errortime As String() = lb_critical.SelectedItem.Split({" | "}, StringSplitOptions.RemoveEmptyEntries)
Dim errortimefound As DateTime = Convert.ToDateTime(errortime(0).ToString())
downtime = DateTime.Now - errortimefound
uptime = DateTime.Now - Convert.ToDateTime(downtime.ToString())
When I run this I get error with downtime variable.
To try and resolve, I tried converting the variables to all DateTime before deducted them, had a look on the internet but wasn't successful.
Could anyone identify what I am doing wrong here.
Thank you Andrew for improved code, but unfortunately I'm still getting the error. Please see the image below: