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

Days Calculated through a selection of records

Status
Not open for further replies.

Halliarse

IS-IT--Management
Jan 8, 2007
213
GB
Help!!

I'm using Crystal Reports 2011

I have a report which reports the number of days a support ticket has been open. within my database, there is a history table that contains ststus changes within the support ticket. I need to be able to calculate the number of days that the support ticket has been in a 'Pending' state.

The table has fields entry_date and entry_text and the text contains 'Status changed from Open to Pending' and 'Status changed from Pending to Open' and there could be multiple times where the ticket changed between Open and Pending.

How do I loop through the records and calculate the pending days?

Any assistance in the way forward would be appreciated!

Thanks

Steve
 
Make sure records are sorted ascending by {table.entry_date}. Create a formula like this and put it in the detail section:

Whileprintingrecords;
Datevar start := date(9999,9,9);
Datevar end := date(0,0,0);
Numbervar pending;

If “Open to Pending” in {table.entry_text} then
start := {table.entry_date};
If “Pending to Open” in {table.entry_text} then
end := {table.entry_date};
if not onfirstrecord and
start < end then
pending := pending + end-start;
If onlastrecord and
end < start then
pending := pending + currentdate-start;
pending

In the report footer add the display formula:

Whileprintingrecords;
Numbervar pending;

Be sure to replace my quote marks with your own if you copy the formula.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top