Jump to content

Time Duration


MacNut

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

Recommended Posts

I need a way to calculate duration between two times & frames.

00:00:00:00 (hours, minutes, seconds, frames)

Frames are between 0-24.

I have setup four start fields and four end fields

how do I get the total duration?

[This message has been edited by MacNut (edited February 09, 2001).]

Link to comment
Share on other sites

I can't see an easy way of doing this! It seems to me that you need to find the difference of each part separately either by using Left [text,number}; Right[text,number and Middle[text,start,number] or by entering each part in four separate fields and then doing the calculation that way. This way would seem to me to be the best since you can use number fields.

Link to comment
Share on other sites

John is correct. You might be able to use normal time calculations to subtract the times, then fix it up for frames. For instance, if the times are the same, just subtract the frame numbers. It's just reinventing a form of subtraction, except when frame 1 is greater than frame 2, you have to borrow seconds. For instance:

01:01:55:55 Time 1

01:01:59:34 Time 2

Time 2 - Time 1

Separate each number into T1 and F1, T2 and F2. T1 and T2 are time fields

DeltaT =

Case(

T2 >= T1 and F2 >= F1, T2 - T1,

T2 > T1 and F2 < F1, T2 - T1 - 1,

etc.

DeltaF =

T2 >= T1 and F2 >= F1, F2 - F1,

T2 > T1 and F2 < F1, (F2 + 24) - F1,

etc.

I'm not going to take the time to work it all out for you, but this is the general idea. Based upon the values of times and frames, you can take care of all cases with both positive and negative time/frame results. After DeltaT and DeltaF are calculated you can put them back together for display with:

TimeToText(DeltaT) & ":" & Right("00" & NumberToText(DeltaF),2)

We used to do rallye times on a pocket calculator using a trick of adding a zero between hours and and minutes 12:55 --> 12055. In this way you can add and subtract hours and minutes. All you have to do when something other than zero shows up in the middle digit is to add or subtract 940, as appropriate. I'm sure a similar system could also be created as an alternative.

-bd

(If you need to have this method worked out for you, FM is NOT just a FMFORUMS hobby for me!, contact me by email)

Link to comment
Share on other sites

I suggest converting everything to frames like so:

TotalFrames1 = ((((Hours1 * 60)+ Minutes1)*60 + Seconds1)*24)+ Frames1

TotalFrames2 = ((((Hours2 * 60)+ Minutes2)*60 + Seconds2)*24)+ Frames2

FramesDifference = TotalFrames1 - TotalFrames2

Then convert back to Hour/Minutes/Seconds/Frames:

Hours = Int(FramesDifference/(60*60*24))

Minutes = Mod(Int(FramesDifference/(60*24)),60)

Seconds = Mod(Int(FramesDifference/24),60)

Frames = Mod(FramesDifference,24)

I didn't check the math here too carefully, but the basic idea should work.

Link to comment
Share on other sites

This topic is 8495 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.