I've searched for a few hours and found quite a bit on date time differences but am not having any luck figuring out how to get the difference between 2 dates where i'm only concerned with hours and minutes. So my apologies for this in advance.
I'm not concerned with years, months and seconds, only hours and minutes.
I'd like to do the following for a work hours time calculation.
Hours allowed to work: 40 hours 0 minutes
Current Hours worked: 33 hours 12 minutes
Remaining hours left to work: 6 hours 48 minutes
I've seen several posts about using date time / period / date.Utils etc... but can't figure out how to get this result. I'd greatly appreciate any links and or thoughts on how I can accomplish this. Thank you!
This appears to be a simple arithmetic problem unless I did not grasp your intent:
B4X:
Log(TimeDiff(40,0,33,12))
B4X:
Sub TimeDiff(hallowed As Int, minutesallowed As Int, curh As Int, curminutes As Int) As String
Dim diff As Double = (hallowed*60+minutesallowed) -(curh*60+curminutes)
Return $"${Floor(diff/60)} hours ${(diff Mod 60)} minutes"$
End Sub
This appears to be a simple arithmetic problem unless I did not grasp your intent:
B4X:
Log(TimeDiff(40,0,33,12))
B4X:
Sub TimeDiff(hallowed As Int, minutesallowed As Int, curh As Int, curminutes As Int) As String
Dim diff As Double = (hallowed*60+minutesallowed) -(curh*60+curminutes)
Return $"${Floor(diff/60)} hours ${(diff Mod 60)} minutes"$
End Sub
I've searched for a few hours and found quite a bit on date time differences but am not having any luck figuring out how to get the difference between 2 dates where i'm only concerned with hours and minutes.
I've seen several posts about using date time / period / date.Utils etc... but can't figure out how to get this result. I'd greatly appreciate any links and or thoughts on how I can accomplish this.