Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Display latest date Post Reply Post New Topic
Author Message
cottie
Newbie
Newbie
Avatar

Joined: 07 Nov 2007
Location: Philippines
Online Status: Offline
Posts: 3
Quote cottie Replybullet Topic: Display latest date
     Posted: 07 Nov 2007 at 4:42pm
Hi!
 
Is there a way wherein I can compare numerous field dates and display only the latest date.
 
For example:
field 1    7/1/2007
field 2    7/9/2007
field 3    7/10/2007
 
With this values I just need to display field 3 which is the latest date.
 
Thanks...
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 08 Nov 2007 at 12:05am
I would use the Maximum() function. However, this function only works with arrays, so I would convert the list to an array dynamically. I discuss this programming trick and many others, in Chapter 7, Writing Formulas, of my new book.

Maximum(MakeArray({field1}, {field 2}, {field 3}));



Edited by BrianBischof - 08 Nov 2007 at 12:06am
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 08 Nov 2007 at 1:56pm

Do you have any groups in your report?  If so, another option is to add a descending sort on the date field and then put all of your data in the group header (NOT Footer!) for your inner group.    This will display just the first "detail" record, which will be the most recent date because of the way the data is sorted.

-Dell

IP IP Logged
Frank in VA
Groupie
Groupie
Avatar

Joined: 15 Nov 2007
Location: United States
Online Status: Offline
Posts: 46
Quote Frank in VA Replybullet Posted: 07 Dec 2007 at 11:11am
A co-worker and myself figured out a way to do this using the Maximum function.  In the Section Expert of the Details section we put the following code in the formula editor of the Suppress option:
 
{End_date} <> Maximum ({End_Date})
 
I tested this with 2 to 4 records and it gives me the most current date each time.  Hope this helps.
Frank
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