Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Bottom N Post Reply Post New Topic
Author Message
iami21
Newbie
Newbie


Joined: 20 Jul 2009
Online Status: Offline
Posts: 11
Quote iami21 Replybullet Topic: Bottom N
    Posted: 21 Jul 2009 at 2:04am
i created a report that has datetime columns for certain events. i created a datediff formula to get the time difference (in minutes) between two events.  Say we have one transaction with transaction number 0001. Transaction 0001 has 4 rows, each with different values for EVENT1 (datetime), BUT the same values for EVENT2.  Now I want to show only the row with the smallest datediff value, the problem is there are datediff results with negative values and when i try to get the Nthsmallest it will include the negative value, and i only want the lowest positive value to show. is there a way i can do that? Thanks very much! my knowledge of crystal report is very basic only.
Big%20smile
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 21 Jul 2009 at 6:14am
In your formula where you calculate the datediff...if it is negative, make it really large instead.  Something like:
local datetimevar diff := datediff(d, {table.event1}, {table.event2});
 
if diff<0 then diff := 1000000;
 
diff
 
HTH
IP IP Logged
iami21
Newbie
Newbie


Joined: 20 Jul 2009
Online Status: Offline
Posts: 11
Quote iami21 Replybullet Posted: 21 Jul 2009 at 7:16pm
hello lockwelle thanks for the suggestion, i tried it but it returned a boolean ..Confused
i did it this way
NumberVar X := datediff ("n",{table.EVENT1},{table.EVENT2});

    if x < 0 then x = 1000

i think i did something wrong....
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 22 Jul 2009 at 7:17am
you compared instead of assigned, should be x:=1000
IP IP Logged
iami21
Newbie
Newbie


Joined: 20 Jul 2009
Online Status: Offline
Posts: 11
Quote iami21 Replybullet Posted: 23 Jul 2009 at 2:12am
i missed the colon. thanks! worked perfectly!! keep up the good work!Big%20smile

Edited by iami21 - 23 Jul 2009 at 2:13am
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.032 seconds.