Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sum of Formula

Status
Not open for further replies.

kwj1027

IS-IT--Management
Aug 10, 2004
28
0
0
US
My formula is:

if PreviousIsNull({F57041.Q1TDTE}) then 0 else
datediff('s', Previous({F57041.Q1TDTE}),{F57041.Q1TDTE})

which creates a column of values (seconds). I need to get the sum of seconds but am not sure how to on a formula field.

Assistance is greatly appreciated.
 
You post nothing about the layout of the report, or where your formula is or where the sum is supposed to be displayed, so we have to guess, please take the time to think your posts through and provide basic information.

Modify your formula to:

whileprintingrecords;
numbervar MyTotal;
if not(PreviousIsNull({F57041.Q1TDTE})) then
MyTotal:=MyTotal+datediff('s', Previous({F57041.Q1TDTE}),{F57041.Q1TDTE});
if PreviousIsNull({F57041.Q1TDTE}) then 0 else
datediff('s', Previous({F57041.Q1TDTE}),{F57041.Q1TDTE})

Then you can display the sum in the report footer, as in:

whileprintingrecords;
numbervar MyTotal

If it's in a group that you need the total, display in the group footer and you'll need a reset for the variable in the group header, as in:

whileprintingrecords;
numbervar MyTotal:=0

As you can see you force us to start guessing at what you have and what you need if you don't take a little time to describe what you have and where, and what you need.

You should also always post your software version and the database being used as there are often more efficient ways by leveraging the database.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top