Jump to content

This topic is 7285 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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...

Posted

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...

Posted

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...

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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...

Posted

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...

Posted

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...

Posted

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.

Posted

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.

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.