Answered # sum duration time

AndreRet 362 Discussion Starter inahrun AndreRet 362 Discussion Starter inahrun AndreRet 362 AndreRet 362 Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...

0

You need to break down the minutes from the seconds first, then calculate the seconds. If more than 60, convert to minutes. Calculate the minutes PLUS those carried over from seconds.:)

Have a look at THIS link on how to convert them....

0

thanks 4 the response..but i still cannot find the solution..i'm new in crystal report..so,i dunno how to use the function given..

my situation : Excel is my sources.And my sources is not in time..So that i convert the sources to time using this formula:

//time format

stringvar x := totext({Sheet1_.Duration});

time(0,val(left(x,2)),val(right(x,2)))

then, i want to calculate the duration time that need a result as my previous post.

I've tried several things, but can't seem to come up with the correct formula or combination of formulas that work. Any suggestions would be great!

0

You are using VB6 and Crystal Reports together, am I right?

If so, the result from your above code is then giving you a value in time i.e. "1:05" gives you one minute five seconds. For that reason the link in my previous post which will break down the 5 seconds from the 1 minute. It will do so with all the other results. The following will then calculate the seconds, convert to minutes and give a total result -

```
Dim xSec As Integer, xMin As Integer, xResult As Integer
xSec = Val(48) + Val(5) + Val(45) 'All the seconds broken down
xMin = Val(1) + Val(2) 'All the minutes broken down
'Convert seconds to minutes
If xSec => 60 And < 120 Then
xSec = xSec - 60
xMin = xMin + 1
ElseIf xSec => 120 And < 180
xSec = xSec - 120
xMin = xMin + 2
'Do the same for all other more minutes
End If
xResult = xSec & ":" & xMin
xResult = Format(xResult, "mm:ss")
```

0

i'm using crystal report only and it give me 2 choices..which is use basic syntax or crystal syntax..if i use your formula,its error there : a variable type(for example,'string')is missing

so how?thanks

0

I am not at all versed in functions and naming conventions in Crystal Reports. The above code will however be the basic principles to use when calculating the sum. I have only used CR in my applications coding in VB6...:)

I saw that the "Integer" type for instance is called "Int" in CR....

Have a look at THIS link for more information and to "convert" the above code.

Sorry I can't be of more assistance.

0

Good luck and happy coding.:)

If you find a solution, please paste it here for future members who might have the same problem.

If you are not going to use this thread anymore, please mark it as solved so it can be closed off, thanks.:)

This question has already been answered. Start a new discussion instead.

Recommended Articles

When I execute this progammatically, I get a table with row heights much larger than when I do this manually.

Note : Sel is the Word.Selection object and the Clipboard contains an Excel Table.

```
public void AddClipboard()
{
Sel.PasteExcelTable(false,false, false);
var t = Sel.Tables[Sel.Tables.Count];
t.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent);
}
```

the function that I created to find the ...