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

DateDiff Formula between instances.

Status
Not open for further replies.

mdelgado100

Technical User
Jul 14, 2004
13
US
I’m working in Crystal 8 and using Oracle database.

I’ve created a report that can calculate the date and time of an entry positing upto the current time and date. So in other words I can tell you how long ago an entry was made. See formula below

I ‘m don’t know how to construct a formula that could give me the difference in time between each entry. (This report contains multiple instances of entries) What is, the time that has elapsed since any two entries first or last or anywhere in-between.

I appreciate any help or direction you can give me.

Thanks ~ md
----------------------------

(Time Elapsed Since Last Entry) Formula

dateTimeVar dt1:= {Incident_Details.LastModified};
DateTimeVar dt2:= currentdatetime;

if ({Incident_Details.LastModified}) <> currentdatetime
then
(Numbervar age := datediff("s", dt1,dt2);)
else 0



 
Assuming that this formula is in the details, just use the previous function against it:

{@Time Elapsed Since Last Entry}-previous({@Time Elapsed Since Last Entry})

Using statements such as "(This report contains multiple instances of entries)" doesn't help us, try to use data or report related technical terms. Explain where the field is, for instance if it's in the details then my formula will work, if it's in a group section, then it probably won't, so state specifics and try to avoid stating business terms, they aren't useful here.

-k
 
Synapsevampire or anyone,

I have to thank you , while I don't really know what you said, your formula for the most part did work. So anyway Thanks.

When the formula below runs:

{@Time Elapsed Since Last Entry}-previous({@Time Elapsed Since Last Entry})

What is returned is the accurate result as long as there are two instances to compare.

1. {@Time Elapsed Since Last Entry}
(-)
2. previous({@Time Elapsed Since Last Entry})

Now....I going ask you (the only way I know how) about the portion of the formula that is not getting my expected results.

When the formula has only one item (Instance)to with nothing to compare, in all cases it returns a negative number Or a an incorrect amount based on the current date.

1. {@Time Elapsed Since Last Entry} = previous({@Time Elapsed Since Last Entry})
(-)
2. Current date
---------
Formula:

dateTimeVar dt1:= previous({Incident_Details.LastModified});
dateTimeVar dt2:= {Incident_Details.LastModified};
dateTimeVar dt3:= currentdate;

if {Incident_Details.LastModified} <> previous ({Incident_Details.LastModified} )

then
(Numbervar age := datediff("d", dt2,dt1);)
else if

{Incident_Details.LastModified} = previous ({Incident_Details.LastModified})

then

(Numbervar age := datediff("d", dt2,dt3);)

else 0;
 
Do a summary count of the number of 'instances' in each group, I assume you are using groups. Then adjust the formula so that it does not attempt comparison or subtraction when there is only one 'instance'

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top