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

Hi, I have a table with date and 2

Status
Not open for further replies.

JPMontreal

Programmer
Feb 18, 2002
153
US
Hi,

I have a table with date and trips like the following:

Trip Leg Departure End
123 1 11/2/03 11/2/03
123 2 11/5/03 11/05/03
123 …
123 5 11/16/03 11/16/03

I need to create a report with the duration of the trip like:

Trip Duration
123 14 days

How could I do that?

Thanks,

Jean-Paul.


Jean-Paul
Montreal
To send me E-Mail, remove “USELESSCODE”.
jp@USELESSCODEsolutionsvba.com
 
First group on {table.trip}, and then create a formula {@duration}:

datediff("d",minimum({table.departure},{table.trip}),maximum({table.end},{table.trip}))

To add the word "days" change the formula to:

totext(datediff("d",minimum({table.departure},{table.trip}),maximum({table.end},{table.trip})),0,"") + " days"

-LB
 
or another way without using summary functions

Group 1 by trip first and Group 2 by leg

In the Group 1 header place this formula

//@CaptureLeg1 (suppress this formula)

WhilePrintingRecords;
DateVar StartDate := {Table.Departure};

Unless you want to see the details of the trip then suppress the details

In the Group 1 footer create the following display formula

//@DisplayTripDuration

WhilePrintingRecords;
DateVar StartDate ;
NumberVar duration;

duration := datediff("d",StartDate,{Table.end})

"Duration of Trip " + {Table.Trip} + ": " + totext(duration,0)

The header will trap the first record and the footer traps the last record of a trip.

Et Voila....c'est fini!


Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Thanks,

Both solution works find.



Jean-Paul
Montreal
To send me E-Mail, remove “USELESSCODE”.
jp@USELESSCODEsolutionsvba.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top