Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Compare Two Dates and Assign Code Post Reply Post New Topic
Author Message
dpanders
Newbie
Newbie


Joined: 28 Apr 2011
Online Status: Offline
Posts: 8
Quote dpanders Replybullet Topic: Compare Two Dates and Assign Code
     Posted: 28 Apr 2011 at 10:46am
I would like to analyze a completed date against a due date and assign a code (that I can later count) based on timeliness of completion.
 
Essentially my data looks like this:
 
Encounter Number | Type of Review | Review Completed | Next Review Due
1234567              | Initial              | 4/1/2011              | 4/4/2011
1234567              | Concurrent       | 4/5/2011              | 4/8/2011
1234567              | Concurrent       | 4/20/2011            | 4/23/2011
 
Parameters for Timeliness:
On Time: Completed <= 3 days from Next Review Date from previous review
Late: Completed 4-7 days after Next Review Date from previous review
Extremely Late: >7 days after Next Review Date from previous review
 
Complicating things is that the next review date is entered on the current review which tells the database to generate a new review on that date. So the completed date has to be compared to the previous next review date to make any sense.
 
Is there a way to do this in Crystal? I know I can do it manually, but it is labor intensive.
Darren P. Anderson, MSN, RN

Manager, Utilization Management
Vidant Medical Center
2100 Stantonsburg Road
Greenville, NC 27834

Phone (252) 847-2402
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 28 Apr 2011 at 11:42am
group by encounter number, i guess order by next review date
 
create a formula that resets every new encounter,
and stores in a shared datetimevar the value of the 'next review date'
if the date is available, compare the completed against the shared variable and determine teh value...something like:
in group header
shared datetimevar nextDate := "1/1/1900"
""//hides the reset
 
in the detail section:
shared datetimevar nextDate;
local numbervar daysElapsed;
 
if nextDate <> "1/1/1900" then
  daysElapsed := datediff("d",{table.field}, nextDate);
if daysElapsed > 7 then
  "very late"
else
  if daysElapsed >3 and daysElapsed < 8 then
    " late"
  else
    "on time"
 
 
 
I might have the datediff function backwards, you might need to reverse the {table.field} and nextDate if the values are negative.
 
HTH
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum