Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Time Code Duration Formula Post Reply Post New Topic
Author Message
cornish
Newbie
Newbie


Joined: 17 May 2012
Location: United Kingdom
Online Status: Offline
Posts: 3
Quote cornish Replybullet Topic: Time Code Duration Formula
     Posted: 17 May 2012 at 2:25am
Hi

I am trying to create a formula to calculate the TimeCode duration between the start and end time of a timecode. The format has to be hh:mm:ss:ff (hours:minutes:seconds:frames)

Im finding it tricky as the frames i need calculated up to 25 frames, unlike the hhmmss which obviously is 60seconds 60minutes etc...

If anyone has any tips or tricks I would be very grateful.

Thanks
Cornish
did ee'er'no?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 17 May 2012 at 6:35am
well, I am assumming that the frames is not encoded, but is a field unto itself...
 
I would use DateDiff to give the time difference and then to format as desired into a string...then add the frames onto the string.
 
if the frame is encoded in a partial second, I would still start with DateDiff, say get the time in seconds.  I would strip off the whole seconds part, leaving a fractional part, then you should be able to divide by your fps to get the frames.
you can then use the whole seconds to format as a time using totext(totalseconds, "hh:mm:ss:") + totext(frames, "", 0)
 
HTH
IP IP Logged
cornish
Newbie
Newbie


Joined: 17 May 2012
Location: United Kingdom
Online Status: Offline
Posts: 3
Quote cornish Replybullet Posted: 18 May 2012 at 1:09am
Thanks for responding. The time I am trying to format in to a timecode is a result from a formula I created. For example an output at the moment just comes out as a number i.e 02341223... So it is not a field, if it was a field i could just format as I have done with the start and end times.
I will give it a go and get back to you.
Thanks
did ee'er'no?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 21 May 2012 at 3:58am
I'm not sure, but if the value you are returning is in the 'right' format, you might still be able to use DateDiff.  If memory serves me, the serial date has the whole number value as the number of days from point in time, and the fractional part is what fraction of the day...12 noon is 1/2 of a day so the value would be .5.  This extends to some small measure of the day...at least to milliseconds.
 
It's a thought. Hope it helps
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 21 May 2012 at 10:20pm
The following will calculate from your start time code and end time code the total difference in frames between the two - from there we can calculate the total seconds to be used in a dateadd and then add the remaining frames on to the end of that.
 
Change the startcode and endcode variables to the relevant fields in your table.
 
stringvar startcode:="02341223";
stringvar endcode:="02341422";
numbervar array s;
numbervar array e;
numbervar x;
numbervar array f:= [90000,1500,25,1];
redim s[4];
redim e[4];
for x:= 1 to 4 do (
    s[x] := tonumber(mid(startcode,(x*2)-1,2))*f[x];
    e[x] := tonumber(mid(endcode,(x*2)-1,2))*f[x];
);
numbervar framedif:= sum(e) - sum(s);
numbervar secdif:= truncate(framedif/25);
Numbervar rframes:= remainder(framedif,25);
totext(dateadd("s",secdif,#00:00:00#),"HH:mm:ss")&":"&totext(rframes,0,"")
 
If you have other fields in your database that give you the frame number rather than us trying to calculate is from the timecode you've created the only thing you need of that is the last 4 lines, slightly modified ofcourse.
 
Regards,
Ryan.


Edited by rkrowland - 22 May 2012 at 12:53am
IP IP Logged
cornish
Newbie
Newbie


Joined: 17 May 2012
Location: United Kingdom
Online Status: Offline
Posts: 3
Quote cornish Replybullet Posted: 21 May 2012 at 10:53pm
THankyou very much for that rkrowland! I will try this and see how what result i get

Thanks again!
did ee'er'no?
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum