Hi,
I have a database with (among other) following fields; StartTime, StartDate, EndTime, EndDate. (In the code below, called InTid, InDatum, UtTid and UtDatum)
Now I want to add the time difference between StartTime and EndTime on posts with the same date or week or all posts....
I use following code (much reduced regarding selection, reading DB and so on, but this is the important code for the timecalculations):
Presenttime is used for an open timeframe that hasn't been ended yet (time = 00:00:00) so I calculate with current time, that is why it ends up in brackets when displayed at the end.
When running this in the emulator it all works fine, even between different dates....
...but when running it in the phone I always get one hour to much.
In the emulator totaltime is (for example) 4:23 and presenttime is 1:25 and adds up to 5:48.
In the phone totaltime gets 5:23, presenttime gets 2:25 and they adds up to 6:48.
As you see all time presented is one hour to much, also the added time which should be two hors more instead.
So the problem is in 'DateTime.Time(totaltime)' conversion.
But why???? And only in the phone?
I have a database with (among other) following fields; StartTime, StartDate, EndTime, EndDate. (In the code below, called InTid, InDatum, UtTid and UtDatum)
Now I want to add the time difference between StartTime and EndTime on posts with the same date or week or all posts....
I use following code (much reduced regarding selection, reading DB and so on, but this is the important code for the timecalculations):
B4X:
Dim totaltime, presenttime As Long
totaltime = 0
presenttime = 0
DateTime.TimeFormat = "HH:mm"
DateTime.DateFormat="yyyy-MM-dd"
For i = 0 To crnames.RowCount
crnames.Position = i
If crnames.GetString("uttid") <> "00:00:00" Then
totaltime=DateTime.DateTimeParse(crnames.GetString("utdatum"), _
crnames.GetString("uttid"))-DateTime.DateTimeParse(crnames.GetString("indatum"), _
crnames.GetString("intid"))+totaltime
Else
presenttime=DateTime.now - DateTime.DateTimeParse(crnames.GetString("indatum"), _
crnames.GetString("intid"))
End If
Next
If presenttime = 0 Then
Text = "Total time: " & DateTime.Time(totaltime)
Else
Text = "Total time: " & DateTime.Time(totaltime) & " + " & DateTime.Time(presenttime) & _
" (" & DateTime.time(totaltime + presenttime) & ")"
End If
Presenttime is used for an open timeframe that hasn't been ended yet (time = 00:00:00) so I calculate with current time, that is why it ends up in brackets when displayed at the end.
When running this in the emulator it all works fine, even between different dates....
...but when running it in the phone I always get one hour to much.
In the emulator totaltime is (for example) 4:23 and presenttime is 1:25 and adds up to 5:48.
In the phone totaltime gets 5:23, presenttime gets 2:25 and they adds up to 6:48.
As you see all time presented is one hour to much, also the added time which should be two hors more instead.
So the problem is in 'DateTime.Time(totaltime)' conversion.
But why???? And only in the phone?