Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Need Formula Post Reply Post New Topic
Author Message
caddy
Newbie
Newbie
Avatar

Joined: 04 Jun 2010
Location: United States
Online Status: Offline
Posts: 2
Quote caddy Replybullet Topic: Need Formula
    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

 

 

 

 

 



Edited by caddy - 07 Jun 2010 at 1:35am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet 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.
IP IP Logged
caddy
Newbie
Newbie
Avatar

Joined: 04 Jun 2010
Location: United States
Online Status: Offline
Posts: 2
Quote caddy Replybullet 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");
 
 


Edited by caddy - 09 Jun 2010 at 2:26am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet 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
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.035 seconds.