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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateDiff detail/group problem

Status
Not open for further replies.

slickBT

IS-IT--Management
Joined
Aug 27, 2003
Messages
3
Location
US
I am using the following to determine the interval between the current record and the previous record in my report.

WhilePrintingRecords;
NumberVar Counter := Counter + 1;
NumberVar Diff :=
If Counter = 1
Then Diff := 0
Else Diff := DateDiff('s',Previous({@TimeStamp}),{@TimeStamp});

This formula doesn't reset for my groupings. How do I set this up so the DateDif for the first record in the detail of each grouping is 0, instead of calculating the DateDiff between the last record of the previous group and the first record of the current group?

Thanks,
SlickBT
 
Here is an option; Change your formula to this:
Code:
WhilePrintingRecords;
NumberVar Counter := Counter + 1;
NumberVar Diff := 
If Counter = 1 OR (Previous({table.group_field}) <> {table.group_field}) Then
    Diff := 0
Else 
    Diff := DateDiff('s',Previous({@TimeStamp}),{@TimeStamp});


~Brian
 
You don't really need to use variables here. The following should work, where {table.group} represents your group field:

if {table.group} = previous({table.group}) then
DateDiff('s',Previous({@TimeStamp}),{@TimeStamp}) else 0


...Although you haven't shared your timestamp formula--it's always a good idea to share the contents of formulas, since that can be critical in what methods work or not.

-LB
 
bdreed35,

Your solution worked for me, thank you.

lbass,

I am going to try out your suggestion as well, thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top