Hi,
I am trying to work out how to calculate the minutes between 2 times.
For Example:
Tue, 18-07 17:11 and Wed, 19-07 20:24
I did look at the following code but wasn't sure on what I need to use for D1, T1, D2, T2.
I know D1, T1 D2, T2 is the date and time, but wasn't sure on how to pass on this value based on my time/date as per my example above.
Any ideas ?
I am trying to work out how to calculate the minutes between 2 times.
For Example:
Tue, 18-07 17:11 and Wed, 19-07 20:24
I did look at the following code but wasn't sure on what I need to use for D1, T1, D2, T2.
I know D1, T1 D2, T2 is the date and time, but wasn't sure on how to pass on this value based on my time/date as per my example above.
B4X:
Sub DateBetweenTwoDates(D1 As String, T1 As String, D2 As String, T2 As String)
Dim start, endTime, t As Long
start = DateTime.DateTimeParse(D1, T1)
endTime = DateTime.DateTimeParse(D2, T2)
Dim days, hours, minutes, seconds As Int
t = Abs(endTime - start)
days = Floor(t / DateTime.TicksPerDay)
hours = Floor((t Mod DateTime.TicksPerDay) / DateTime.TicksPerHour)
minutes = Floor((t Mod DateTime.TicksPerHour) / DateTime.TicksPerMinute)
seconds = Floor((t Mod DateTime.TicksPerMinute) / DateTime.TicksPerSecond)
Log("Days = " & days)
Log("Hours = " & hours)
Log("Minutes = " & minutes)
Log("Seconds = " & seconds)
log("Days = " & days & CRLF & "Hours = " & hours & CRLF & "Minutes = " & minutes & CRLF & "Seconds = " & seconds)
End Sub
Any ideas ?