# Time calculation

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

## Recommended Posts

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

##### Share on other sites

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

##### Share on other sites

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

##### Share on other sites

Try:

EndTime - StartTime + Time ( 24 * ( EndTime < StartTime ) ; 0 ; 0 )

##### Share on other sites

Try:

EndTime - StartTime + Time ( 24 * ( EndTime < StartTime ) ; 0 ; 0 )

##### Share on other sites

Try:

EndTime - StartTime + Time ( 24 * ( EndTime < StartTime ) ; 0 ; 0 )

##### Share on other sites

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.

##### Share on other sites

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.

##### Share on other sites

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.

##### Share on other sites

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.

##### Share on other sites

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.

##### Share on other sites

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.

##### Share on other sites

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

##### Share on other sites

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

##### Share on other sites

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

##### Share on other sites

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.

##### Share on other sites

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.

##### Share on other sites

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.

##### Share on other sites

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

## Create an account

Register a new account