Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Most Recent Date Across Multiple Date Fields Post Reply Post New Topic
Author Message
GENLISA
Newbie
Newbie
Avatar

Joined: 19 Sep 2014
Location: United States
Online Status: Offline
Posts: 5
Quote GENLISA Replybullet Topic: Most Recent Date Across Multiple Date Fields
    Posted: 21 Sep 2014 at 5:57am
Help I'm stuck. Can anyone help me.  I have a report that uses data from multiple date fields and I need a formula that will look at the 6 date fields and if the field is blank pull the previous field.  I put a variable in the report but it is not recognizing it. This is my formula I'm using Crystal Reports X:
 
WhilePrintingRecords;
Global dateTimeVar DateBonusReached:=
DateBonusReached := (If IsNull ({EXTUWRKLOAN.Q6_DATE}) then {EXTUWRKLOAN.Q5_DATE} else {EXTUWRKLOAN.Q6_DATE});
DateBonusReached := (If IsNull ({EXTUWRKLOAN.Q5_DATE}) then {EXTUWRKLOAN.Q4_DATE} else {EXTUWRKLOAN.Q5_DATE});
DateBonusReached := (If IsNull ({EXTUWRKLOAN.Q4_DATE}) then {EXTUWRKLOAN.Q3_DATE} else {EXTUWRKLOAN.Q4_DATE});
DateBonusReached := (If IsNull ({EXTUWRKLOAN.Q3_DATE}) then {EXTUWRKLOAN.Q2_DATE} else {EXTUWRKLOAN.Q3_DATE});
DateBonusReached := (If IsNull ({EXTUWRKLOAN.Q2_DATE}) then {EXTUWRKLOAN.Q1_DATE} else {EXTUWRKLOAN.Q2_DATE})
 
This is the result I am getting:
 
Quote formula Q1_DATE Q2_DATE Q3_DATE Q4_DATE Q5_DATE Q6_DATE
 18-Aug-2014
 27-Aug-2014
 27-Aug-2014
 27-Aug-2014
9/17/2014  12:00:00 AM  12-Sep-2014  17-Sep-2014  18-Sep-2014
 27-Aug-2014
8/30/2014  12:00:00 AM  29-Aug-2014  30-Aug-2014  1-Sep-2014  02-Sep-2014  03-Sep-2014  04-Sep-2014
9/20/2014  12:00:00 AM  19-Sep-2014  20-Sep-2014
9/12/2014  12:00:00 AM  10-Sep-2014  12-Sep-2014  14-Sep-2014  16-Sep-2014  18-Sep-2014
9/5/2014  12:00:00 AM  02-Sep-2014  05-Sep-2014  6-Sep-2014  14-Sep-2014
9/17/2014  12:00:00 AM  15-Sep-2014  17-Sep-2014  19-Sep-2014
 
This is what it is supposed to look like:
 
Quote formula Q1_DATE Q2_DATE Q3_DATE Q4_DATE Q5_DATE Q6_DATE
 18-Aug-2014  18-Aug-2014
 27-Aug-2014  27-Aug-2014
 27-Aug-2014  27-Aug-2014
 27-Aug-2014  27-Aug-2014
 18-Sep-2014  12-Sep-2014  17-Sep-2014  18-Sep-2014
 27-Aug-2014  27-Aug-2014
 04-Sep-2014  29-Aug-2014  30-Aug-2014  1-Sep-2014  02-Sep-2014  03-Sep-2014  04-Sep-2014
 20-Sep-2014  19-Sep-2014  20-Sep-2014
 18-Sep-2014  10-Sep-2014  12-Sep-2014  14-Sep-2014  16-Sep-2014  18-Sep-2014
 14-Sep-2014  02-Sep-2014  05-Sep-2014  6-Sep-2014  14-Sep-2014
 19-Sep-2014  15-Sep-2014  17-Sep-2014  19-Sep-2014
 


Edited by GENLISA - 21 Sep 2014 at 5:59am
IP IP Logged
z9962
Senior Member
Senior Member
Avatar

Joined: 04 Jul 2012
Online Status: Offline
Posts: 161
Quote z9962 Replybullet Posted: 21 Sep 2014 at 9:50pm
Is the date you are after always going to be the latest date?
IP IP Logged
GENLISA
Newbie
Newbie
Avatar

Joined: 19 Sep 2014
Location: United States
Online Status: Offline
Posts: 5
Quote GENLISA Replybullet Posted: 22 Sep 2014 at 2:33am
Yes
IP IP Logged
z9962
Senior Member
Senior Member
Avatar

Joined: 04 Jul 2012
Online Status: Offline
Posts: 161
Quote z9962 Replybullet Posted: 22 Sep 2014 at 2:36am

Then the easiest way is

maximum([{date1},{date2},{date3},{date4},{date5},{date6}])

 

by using the square brackets it turns the values into an array.

You may need to change the default values for Null

IP IP Logged
GENLISA
Newbie
Newbie
Avatar

Joined: 19 Sep 2014
Location: United States
Online Status: Offline
Posts: 5
Quote GENLISA Replybullet Posted: 22 Sep 2014 at 2:44am
Thank you i will try it to see if it works
IP IP Logged
GENLISA
Newbie
Newbie
Avatar

Joined: 19 Sep 2014
Location: United States
Online Status: Offline
Posts: 5
Quote GENLISA Replybullet Posted: 22 Sep 2014 at 3:49am
I'm getting an error saying not enough arguments have been given to the function
IP IP Logged
z9962
Senior Member
Senior Member
Avatar

Joined: 04 Jul 2012
Online Status: Offline
Posts: 161
Quote z9962 Replybullet Posted: 22 Sep 2014 at 3:59am
what does your formula look like?
IP IP Logged
GENLISA
Newbie
Newbie
Avatar

Joined: 19 Sep 2014
Location: United States
Online Status: Offline
Posts: 5
Quote GENLISA Replybullet Posted: 22 Sep 2014 at 11:38am
I was able to figure it out.  I didn't assign a value to my variable.  After I did that it worked.  Thanks for responding

Edited by GENLISA - 22 Sep 2014 at 11:38am
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.031 seconds.