Print Page | Close Window

Need Formula

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2022
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=10189
Printed Date: 31 Mar 2025 at 12:35am


Topic: Need Formula
Posted By: caddy
Subject: Need Formula
Date Posted: 04 Jun 2010 at 8:37am
 
 
Currently it is is calculating on the same line

where it needs to be Calculating first line to second line, i.e.,  ( Doe, George ) 9:26 to ( Does, Lacinda ) 10:08 for a total of 42 Minutes.

The first line ( Doe, George ) really should have 0 minutes since there is no Previous Case Stop for it to use to calculate it.  

 My Current Formula is as follows, though it is incorrect:

 if isNull ({CATH_CASE_EVENT.CASE_END}) then 0 else

    if isNull ({CATH.PATIENT_ON_TABLE}) then 0 else

        DateDiff("n", {CATH.PATIENT_ON_TABLE}, {CATH_CASE_EVENT.CASE_END})

 

I'm trying to get Case Stop ( CATH_CASE_EVENT.CASE_END ) DATE TIME FIELD

 

To

 

On Table (CATH.PATIENT_ON_TABLE) DATETIME FIELD

 

 Would GREATLY appreciate any help I can get on this one....

 
Thanks
 
Steve

 

 

 

 

 




Replies:
Posted By: lockwelle
Date Posted: 07 Jun 2010 at 3:29am
I would try something like:
 
shared datetimevar lastValue;
local numbervar timeDiff := dateDiff("n", {table.field}, lastValue);
 
lastValue := {table.field};
timeDiff
 
It might need some tweeks, lastValue can be set in a group or the report to an initial value of first date, so that the DateDiff is 0, and other options can be added.
 
Hopefully as an alternate of looking at the problem it will get you to a solution.


Posted By: caddy
Date Posted: 09 Jun 2010 at 2:25am

Thanks Lockwelle

 
Current Formula is this:
 ---------------------------------------------------------------------------------

shared datetimevar lastValue;

local numbervar TimeDiff := DateDiff("n", {CATH.PATIENT_ON_TABLE}, lastValue);

 

lastValue := {CATH.PATIENT_ON_TABLE};

timeDiff

-----------------------------------------------------------------------------
My Reset Formula Field in a Group Header ( 5a ) above the line I am printing all my data on ( 5b ).   I'm getting -140 with this formula where I should be getting 42 minutes.   0 is showing for the first field, which is good.
 
Reset formula is as follows:
 
WhilePrintingRecords;
timeVar lastValue :=ctime ("00:00");
 
 


Posted By: lockwelle
Date Posted: 09 Jun 2010 at 2:45am
typically, if you get a negative when you want a positive...especially with dateDiff, just reverse the arguements. So put lastValue first.  (I always get the order mixed up).
 
Now, you are getting 140, instead of 42.  If this is the first time it was 'run', when did things start?  Resetting the start time to midnight and then calculating the minutes from that might throw it off.  I would think that the reset value would be {CATH.PATIENT_ON_TABLE}, as the first time you calculate, the diff is 0, as the values are the same.
 
HTH



Print Page | Close Window