73Challenger Member Licensed User Nov 26, 2022 #1 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!
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!
Solution M M Mahares Nov 26, 2022 73Challenger said: thoughts on how I can accomplish this Click to expand... This appears to be a simple arithmetic problem unless I did not grasp your intent: Code: Copy Log(TimeDiff(40,0,33,12)) Code: Copy 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
73Challenger said: thoughts on how I can accomplish this Click to expand... This appears to be a simple arithmetic problem unless I did not grasp your intent: Code: Copy Log(TimeDiff(40,0,33,12)) Code: Copy 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
M Mahares Expert Licensed User Longtime User Nov 26, 2022 #2 73Challenger said: thoughts on how I can accomplish this Click to expand... This appears to be a simple arithmetic problem unless I did not grasp your intent: Code: Copy Log(TimeDiff(40,0,33,12)) Code: Copy 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 Upvote 2 Solution
73Challenger said: thoughts on how I can accomplish this Click to expand... This appears to be a simple arithmetic problem unless I did not grasp your intent: Code: Copy Log(TimeDiff(40,0,33,12)) Code: Copy 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
E emexes Expert Licensed User Longtime User Nov 26, 2022 #3 73Challenger said: 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. Click to expand... I would have thought that this post fits your mission perfectly, except that I've used a single number for time ie h.hhh rather than hh:mm: https://www.b4x.com/android/forum/t...-in-pm-and-on-other-in-am.144377/#post-915342 If let me know where it runs off the track for your mission, I will happily adjust it accordingly for an additional 20% bonus fee. ? Upvote 1
73Challenger said: 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. Click to expand... I would have thought that this post fits your mission perfectly, except that I've used a single number for time ie h.hhh rather than hh:mm: https://www.b4x.com/android/forum/t...-in-pm-and-on-other-in-am.144377/#post-915342 If let me know where it runs off the track for your mission, I will happily adjust it accordingly for an additional 20% bonus fee. ?
73Challenger Member Licensed User Nov 26, 2022 #4 @Mahares - Worked perfectly, thank you. @emexes - Thank you for your response as well, It would have worked too. Thanks again! The members in this community always come through! Upvote 0
@Mahares - Worked perfectly, thank you. @emexes - Thank you for your response as well, It would have worked too. Thanks again! The members in this community always come through!