You should not save the datetime in the database as string. But if you must, here is how you can convert datetime to and from string. Find the duration on a timespan
Sub Main()
' generate two datetimes two seconds apart
Dim d1 As DateTime = DateTime.Now
Threading.Thread.Sleep(2000)
Dim d2 As DateTime = DateTime.Now
Console.WriteLine("d1: {0}, d2: {1}", d1, d2)
' convert the datetimes to strings and assign them
Dim s1 As String = d1.ToString("HH:mm:ss")
Dim s2 As String = d2.ToString("HH:mm:ss")
Console.WriteLine("s1: {0}, s2: {1}", s1, s2)
' parse the strings back into datetimes
d1 = DateTime.Parse(s1)
d2 = DateTime.Parse(s2)
Console.WriteLine("d1: {0}, d2: {1}", d1, d2)
' find the duration in total hours, minutes, or seconds
' the operation is performed on a timespan resulting from `DateTime.Subtract`
Dim hours = d2.Subtract(d1).TotalHours
Dim minutes = d2.Subtract(d1).TotalMinutes
Dim seconds = d2.Subtract(d1).TotalSeconds
' note: use one of the following, as they represent the same duration
' not a composite time
Console.WriteLine("Duration in hours: {0}", hours)
Console.WriteLine("Duration in minutes: {0}", minutes)
Console.WriteLine("Duration in seconds: {0}", seconds)
Console.ReadLine()
End Sub
Output
d1: 11/29/2016 2:35:55 PM, d2: 11/29/2016 2:35:57 PM
s1: 14:35:55, s2: 14:35:57
d1: 11/29/2016 2:35:55 PM, d2: 11/29/2016 2:35:57 PM
Duration in hours: 0.000555555555555556
Duration in minutes: 0.0333333333333333
Duration in seconds: 2
Note: if you use that format, you will throw away the date component. The system will assume today and you may run into issues if the application is run overnight. Personally, I would supply "yyyy-MM-dd HH:mm:ss", or no format at all (the default format).