Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Find 2nd latest date Post Reply Post New Topic
Author Message
mleu
Newbie
Newbie


Joined: 21 Oct 2013
Location: United States
Online Status: Offline
Posts: 3
Quote mleu Replybullet Topic: Find 2nd latest date
     Posted: 13 Nov 2013 at 5:30pm
Hi everyone,

I hope someone can help me with this problem...

I need to find the amount of the 2nd latest date updated on a list of orders.

For example:
Order#; Updated Date; Amt
1; 11/11; $1
1; 11/12; $2
1; 11/14; $3
2; 11/11; $1
2; 11/12; $2
2; 11/13; $3
2; 11/14; $4

So, I need:
1; 11/12; $2
2; 11/13; $3

Thank you in advance for any advice.
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 14 Nov 2013 at 2:23am
could you possibly group on date in descending order then just use NthLargest to get the 2nd latest date? 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 14 Nov 2013 at 4:46am
you could also group by order#, in the group header put a formula like:
shared numbervar ln := 1;
shared numbervar amt:= -1;
shared datetimevar dt:="1/1/1900";
"" //hide the 1 that would show

in the detail section:
shared numbervar ln;
shared numbervar amt;
shared datetimevar dte;

if ln = 2 then(
amt:={table.field};
dte := {table.field1}
);

ln := ln+1;
"" //hide the running line count

finally in the group footer 2 formulas:
shared numbervar amt;

and
shared datetimevar dte;

you could also add in some error checking in case there was no 2nd date...

HTH



Edited by lockwelle - 14 Nov 2013 at 4:47am
IP IP Logged
mleu
Newbie
Newbie


Joined: 21 Oct 2013
Location: United States
Online Status: Offline
Posts: 3
Quote mleu Replybullet Posted: 14 Nov 2013 at 7:34am
Thank you very much bwsanders for your advice, it works great!
IP IP Logged
mleu
Newbie
Newbie


Joined: 21 Oct 2013
Location: United States
Online Status: Offline
Posts: 3
Quote mleu Replybullet Posted: 14 Nov 2013 at 9:31am
Thank you very much lockwelle for your advice, sorry for getting back late, as i spent some time to figure it... but it works well! Thanks again for your help!
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 14 Nov 2013 at 9:34am
glad it works
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