Dim crnames As Cursor
crnames = Main.SQLuser.ExecQuery("SELECT intid, uttid, indatum, utdatum, projekt, kund, projektdescr, week, kommentar FROM time WHERE indatum = '" & lDate & "' ORDER BY intid")
If crnames.RowCount > 0 Then
For i = 0 To crnames.RowCount - 1
crnames.Position = i
If crnames.GetString("indatum")=lDate Then
'My first try, adding like this works
totaltime = totaltime + DateTime.DateTimeParse(crnames.GetString("utdatum"), crnames.GetString("uttid"))-DateTime.DateTimeParse(crnames.GetString("indatum"), crnames.GetString("intid"))
'OR
'My second try and this works also
diff = DateUtils.PeriodBetween(DateTime.DateTimeParse(crnames.GetString("indatum"), crnames.GetString("intid")),DateTime.DateTimeParse(crnames.GetString("utdatum"), crnames.GetString("uttid")))
totaltime = DateUtils.AddPeriod(totaltime, diff)
End If
Next
' So far everything works, totaltime contains the correct number of ticks
' after both ways above
' When doing this it all fails, so how should I convert Ticks to "00:00"
txtTime.Text = "Total tid: " & DateTime.Time(totaltime)
End If