Im using below code which give me these results:
2.12:00:00
1.05:55:14.4679488
How to format the string that will give me a result in 24hours format like these:
60:00:00
29:55:14
Thanks for your help. Im using vb.net 2008.
Dim TimeIn As New System.DateTime
Dim TimeOut As New System.DateTime
For x As Integer = 0 To RecordsDataGridview.Rows.Count - 2
Dim TimeInvalue As String = RecordsDataGridview.Rows(x).Cells(10).Value.ToString()
If Not IsDBNull(RecordsDataGridview.Rows(x).Cells(10).Value) AndAlso RecordsDataGridview.Rows(x).Cells(10).Value.ToString.Length <> 0 Then
TimeIn = DateTime.Parse(TimeInvalue)
End If
Dim TimeOutvalue As String = RecordsDataGridview.Rows(x).Cells(11).Value.ToString()
If Not IsDBNull(RecordsDataGridview.Rows(x).Cells(11).Value) AndAlso RecordsDataGridview.Rows(x).Cells(11).Value.ToString.Length <> 0 Then
TimeOut = DateTime.Parse(TimeOutvalue)
End If
If IsDBNull(RecordsDataGridview.Rows(x).Cells(10).Value()) OrElse RecordsDataGridview.Rows(x).Cells(10).Value() Is Nothing OrElse RecordsDataGridview.Rows(x).Cells(10).Value.ToString.Trim() = "" Then
RecordsDataGridview.Rows(x).Cells(12).Value() = Nothing
End If
If IsDBNull(RecordsDataGridview.Rows(x).Cells(11).Value()) OrElse RecordsDataGridview.Rows(x).Cells(11).Value() Is Nothing OrElse RecordsDataGridview.Rows(x).Cells(11).Value.ToString.Trim() = "" Then
Dim StayingHours2 As TimeSpan = (DateTime.Now - TimeIn)
String.Format("{0:00}:{1:00}:{2:00}", StayingHours2.TotalHours, StayingHours2.Minutes, StayingHours2.Seconds)
RecordsDataGridview.Rows(x).Cells(12).Value() = StayingHours2
Else
Dim StayingHours1 As TimeSpan = (TimeOut - TimeIn)
String.Format("{0:00}:{1:00}:{2:00}", StayingHours1.TotalHours, StayingHours1.Minutes, StayingHours1.Seconds)
RecordsDataGridview.Rows(x).Cells(12).Value() = StayingHours1
End If
Next