Calculate the Duration in seconds

6 posts / 0 new
Last post
Ahmed
Offline
Joined: 09/20/2017 - 05:45
Calculate the Duration in seconds

Hi All,
I need to deal with a field ( numeric type) containing a number called duration with this format for example : 14100 wich mean that the duration is 101 second, another exmaple :
1333800 = 5618 second
1410100=6061 second
So which function ca help me to get the result in second ?
Thank you.

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Ahmed,

I don't get how the calculation works:

14100 / 101 = 139.6

1333800 / 5618 = 237.4

1410100 / 6061 = 232.7

I don't see the correlation between the numer and number of seconds or is there sometype of special formatting that is used to get the seconds.

 

Ahmed
Offline
Joined: 09/20/2017 - 05:45

Hi Brian,
for :
- 14100 mean 1 minute and 41 second and the result in second is 60+41 = 101 second
- 1333800 mena 1 hours 33 minute and 8 second 
In excel  I use this formule to get the result =(TEXTE((A2/100);"00\:00\:00")*86400)
 

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Ahmed,

Here is the equation I came up with to do this:

@Tton(@Ctot(@replace(@Str(TIME, 8, 0), " ", "0"), "HHMMSS"))

First create a virtual numeric field to store the result, then paste the formula into the equation editor and change the TIME for the name of the field.  The equation assumes that the field holding the time is numeric.  

What the equation does is it first takes the numeric time field and changes it to string (@Str, 8 characters long with no decimals).  It then pads it with 0 so that it is 8 characters long (@replace changes the spaces to 0).  I then change the field to a time field using the @Ctot function and a mask of HHMMSS, finally I use the @Tton to take the time field and return the number of seconds.

Hopefully that makes sense.

Brian

Ahmed
Offline
Joined: 09/20/2017 - 05:45

Hi Brian,
Yes, absouletly it makes sense ! 
Thank you very for your helping.

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Not a problem, glad I could be of help.