Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Trying to get max(date)? Post Reply Post New Topic
Author Message
isaacb
Newbie
Newbie


Joined: 19 Feb 2009
Online Status: Offline
Posts: 2
Quote isaacb Replybullet Topic: Trying to get max(date)?
     Posted: 19 Feb 2009 at 2:04pm
<-- Business user, please don't flame me... :)
 
 
I haven't used CR 11 very much (noob), but I have a critical deliverable where I am stuck on the last detail... Any help would be immensely appreciated!
 
I have a column that is calculating a date + 180 days based on logic conditions in other fields, and I am suppressing the date when the conditions are false.
 
Formula #1 is below and it works great.
 
WhilePrintingRecords;
DateVar dep_date;
dep_date := Date({a.date} + 181)
 
 
However, I'm trying to put a max function (Formula #2) in to pull the last date that is not suppressed in that group and for the life of me, I can't figure the code out.
 
WhilePrintingRecords;
datevar ddd;
ddd:=maximum(dep_date)
 
// returns an error "The ) is missing"
 
I'm guessing that the variable is not being set due to the suppression, but I can't figure out how to get around it? If I don't suppress, then the max function just pulls the last date in the group.
 
Please advise oh gurus of crystal! Smile
- Isaac
 
Edit: This may look like a re-post, but the issue is different than the one listed a few lines down... (imo)
 
2nd edit: Could this be because I'm trying to aggregate a formula field and not a database field?


Edited by isaacb - 19 Feb 2009 at 4:42pm
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 20 Feb 2009 at 12:18am
Hi
 
Why don't you try to do Insert Summary and select the date field field and summary type Maximum and insert at group level....
 
Cheers
Rahul
IP IP Logged
despec99
Newbie
Newbie


Joined: 10 Feb 2009
Online Status: Offline
Posts: 22
Quote despec99 Replybullet Posted: 20 Feb 2009 at 8:48am
Originally posted by isaacb

<-- Business user, please don't flame me... :)
 
 
I haven't used CR 11 very much (noob), but I have a critical deliverable where I am stuck on the last detail... Any help would be immensely appreciated!
 
I have a column that is calculating a date + 180 days based on logic conditions in other fields, and I am suppressing the date when the conditions are false.
 
Formula #1 is below and it works great.
 
WhilePrintingRecords;
DateVar dep_date;
dep_date := Date({a.date} + 181)
 
 
However, I'm trying to put a max function (Formula #2) in to pull the last date that is not suppressed in that group and for the life of me, I can't figure the code out.
 
WhilePrintingRecords;
datevar ddd;
ddd:=maximum(dep_date)
 
// returns an error "The ) is missing"
 
I'm guessing that the variable is not being set due to the suppression, but I can't figure out how to get around it? If I don't suppress, then the max function just pulls the last date in the group.
 
Please advise oh gurus of crystal! Smile
- Isaac
 
Edit: This may look like a re-post, but the issue is different than the one listed a few lines down... (imo)
 
2nd edit: Could this be because I'm trying to aggregate a formula field and not a database field?


In the second formula, you need to "re-declare" the "dep_date" shared variable.  That could be why you're receiving that error.

David
IP IP Logged
isaacb
Newbie
Newbie


Joined: 19 Feb 2009
Online Status: Offline
Posts: 2
Quote isaacb Replybullet Posted: 23 Feb 2009 at 10:12am
I figured it out...
 
I created a 3rd formula that sets the value of the last date in the group...
 
WhilePrintingRecords;
datevar tdate;
If {a.date} < {b.date}
then
tdate := date({a.date}) + 181
else tdate := tdate
 
I added this formula into the detail and the footer (required). Works like a charm. Be sure to re-assign the variable to itself in the that last line or it won't work.
 
 
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