tarheel Posted March 15, 2005 Author Posted March 15, 2005 I'm trying to figure out how to calculate the correct elapsed time using the 24 hr format, start time is 23:00 and end time is 02:00. It should be 3:00 but is -21:00. The calculation is (end time - start time)I know there is a way to compensate but I can't figure it out. Any help would be appreciated. Thanks for you time, Bob...
tarheel Posted March 15, 2005 Posted March 15, 2005 I'm trying to figure out how to calculate the correct elapsed time using the 24 hr format, start time is 23:00 and end time is 02:00. It should be 3:00 but is -21:00. The calculation is (end time - start time)I know there is a way to compensate but I can't figure it out. Any help would be appreciated. Thanks for you time, Bob...
tarheel Posted March 15, 2005 Author Posted March 15, 2005 I'm trying to figure out how to calculate the correct elapsed time using the 24 hr format, start time is 23:00 and end time is 02:00. It should be 3:00 but is -21:00. The calculation is (end time - start time)I know there is a way to compensate but I can't figure it out. Any help would be appreciated. Thanks for you time, Bob...
comment Posted March 15, 2005 Posted March 15, 2005 Try: EndTime - StartTime + Time ( 24 * ( EndTime < StartTime ) ; 0 ; 0 )
comment Posted March 15, 2005 Posted March 15, 2005 Try: EndTime - StartTime + Time ( 24 * ( EndTime < StartTime ) ; 0 ; 0 )
comment Posted March 15, 2005 Posted March 15, 2005 Try: EndTime - StartTime + Time ( 24 * ( EndTime < StartTime ) ; 0 ; 0 )
Ender Posted March 15, 2005 Posted March 15, 2005 Just off the top of my head: case(end time - start time < 0; (end time - start time) + 24; end time - start time) There's probably a better way.
Ender Posted March 15, 2005 Posted March 15, 2005 Just off the top of my head: case(end time - start time < 0; (end time - start time) + 24; end time - start time) There's probably a better way.
Ender Posted March 15, 2005 Posted March 15, 2005 Just off the top of my head: case(end time - start time < 0; (end time - start time) + 24; end time - start time) There's probably a better way.
NYPoke Posted March 15, 2005 Posted March 15, 2005 if ( Hour (Start Time) <= Hour (End Time), End Time- Start Time, End Time - Time ( Hours(Start Time) + 24, Minute(Start Time), Second(Start Time) ) ) I didn't test this, so it might require some work on your part. But, the idea is that you need to adjust the Calculation by 24 Hours. You will have to check this, but you should be able to test for the negative result somehow. It would probably be some script steps like: if( Hour(ResultTime) < 0) Set Field( ResultTime, Time( Hour(ResultTime)+24, Minute(ResultTime), Seconds(ResultTime) ) ) endif I haven't tried it, so I am not sure if the -21:00 will give you a -21 in the Hours. If so, this will work. If not, experiment with the If Script Step to catch the negative result.
NYPoke Posted March 15, 2005 Posted March 15, 2005 if ( Hour (Start Time) <= Hour (End Time), End Time- Start Time, End Time - Time ( Hours(Start Time) + 24, Minute(Start Time), Second(Start Time) ) ) I didn't test this, so it might require some work on your part. But, the idea is that you need to adjust the Calculation by 24 Hours. You will have to check this, but you should be able to test for the negative result somehow. It would probably be some script steps like: if( Hour(ResultTime) < 0) Set Field( ResultTime, Time( Hour(ResultTime)+24, Minute(ResultTime), Seconds(ResultTime) ) ) endif I haven't tried it, so I am not sure if the -21:00 will give you a -21 in the Hours. If so, this will work. If not, experiment with the If Script Step to catch the negative result.
NYPoke Posted March 15, 2005 Posted March 15, 2005 if ( Hour (Start Time) <= Hour (End Time), End Time- Start Time, End Time - Time ( Hours(Start Time) + 24, Minute(Start Time), Second(Start Time) ) ) I didn't test this, so it might require some work on your part. But, the idea is that you need to adjust the Calculation by 24 Hours. You will have to check this, but you should be able to test for the negative result somehow. It would probably be some script steps like: if( Hour(ResultTime) < 0) Set Field( ResultTime, Time( Hour(ResultTime)+24, Minute(ResultTime), Seconds(ResultTime) ) ) endif I haven't tried it, so I am not sure if the -21:00 will give you a -21 in the Hours. If so, this will work. If not, experiment with the If Script Step to catch the negative result.
tarheel Posted March 15, 2005 Author Posted March 15, 2005 Outstanding, that did it. Thanks so much for the information and quick response. Now on to the next opportunity. The actual calculation I used is: If ( EndTime < StartTime; EndTime - StartTime + Time ( 24 * ( EndTime < StartTime) ; 0 ; 0 ); EndTime - StartTime)This will correct for the normal 24 hour times and detect the situation where we go over the 24 hour period into the next day and fix the time. Thanks to the other contributors as well. Bob...
tarheel Posted March 15, 2005 Author Posted March 15, 2005 Outstanding, that did it. Thanks so much for the information and quick response. Now on to the next opportunity. The actual calculation I used is: If ( EndTime < StartTime; EndTime - StartTime + Time ( 24 * ( EndTime < StartTime) ; 0 ; 0 ); EndTime - StartTime)This will correct for the normal 24 hour times and detect the situation where we go over the 24 hour period into the next day and fix the time. Thanks to the other contributors as well. Bob...
tarheel Posted March 15, 2005 Author Posted March 15, 2005 Outstanding, that did it. Thanks so much for the information and quick response. Now on to the next opportunity. The actual calculation I used is: If ( EndTime < StartTime; EndTime - StartTime + Time ( 24 * ( EndTime < StartTime) ; 0 ; 0 ); EndTime - StartTime)This will correct for the normal 24 hour times and detect the situation where we go over the 24 hour period into the next day and fix the time. Thanks to the other contributors as well. Bob...
-Queue- Posted March 16, 2005 Posted March 16, 2005 Just so you know, If( EndTime < StartTime; EndTime - StartTime + Time( 24 * (EndTime < StartTime); 0; 0 ); EndTime - StartTime) is equivalent to Comment's calc of EndTime - StartTime + Time( 24 * (EndTime < StartTime); 0; 0 ) The test for EndTime < StartTime at the beginning is redundant since the Time portion will be zero unless EndTime < StartTime already.
-Queue- Posted March 16, 2005 Posted March 16, 2005 Just so you know, If( EndTime < StartTime; EndTime - StartTime + Time( 24 * (EndTime < StartTime); 0; 0 ); EndTime - StartTime) is equivalent to Comment's calc of EndTime - StartTime + Time( 24 * (EndTime < StartTime); 0; 0 ) The test for EndTime < StartTime at the beginning is redundant since the Time portion will be zero unless EndTime < StartTime already.
-Queue- Posted March 16, 2005 Posted March 16, 2005 Just so you know, If( EndTime < StartTime; EndTime - StartTime + Time( 24 * (EndTime < StartTime); 0; 0 ); EndTime - StartTime) is equivalent to Comment's calc of EndTime - StartTime + Time( 24 * (EndTime < StartTime); 0; 0 ) The test for EndTime < StartTime at the beginning is redundant since the Time portion will be zero unless EndTime < StartTime already.
Recommended Posts
This topic is 7285 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now