Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: maximum date Post Reply Post New Topic
<< Prev Page  of 2
Author Message
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 19 Feb 2009 at 2:03am
Hi
 
Can you explain in more detail please,as what codes and how many parameters you are using to filter your report records,because if you are using filters in your record selection formula ii will filter the report as per the code ,So for example if you enter code C you will see records for C with Maximum Date ,and if you enter S as code you will see records for S and not C.
 
So please explain as when you say that you can't suppress records ? and also another parameter means what according to you,also can you paste more sample data ,so that we can help you.....
 
Cheers
Rahul
IP IP Logged
lrcrystaluser
Newbie
Newbie


Joined: 16 Feb 2009
Location: United Kingdom
Online Status: Offline
Posts: 10
Quote lrcrystaluser Replybullet Posted: 24 Feb 2009 at 7:17am
My apologies to all I have not explained myself clearly at all. Here is what I am trying to do:

I have 3 fields: username, date, code
i have a startcode and an endcode string parameter
i have grouped by username then displayed all of that users records

I am trying to calculate the difference in dates where the startdate = the maximum date where code = the startcode parameter and the enddate = the maximum date where code = endcode

for example:
user enters C for startcode and a S for endcode

in the username group header/footer I want to display the   
maximum date where code = C, the maximum date where code = S and the difference in weeks between these 2 dates.

I hope that this better explains what I am trying to do and thanks in advance for any help.
Keep on trying!
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: 27 Feb 2009 at 3:43am
Hi
 
This is what you do...
 
Create two subreports,one for Start Code and One for EndCode.
 
Steps for Start Code Sub-Report ,follow the same steps for EndCode Subreport
 
In those two Sub-Reports
Create Group by
UserName and then
           Code
 
Then in Insert Summary Insert Maximum Date for that Code.
 
suppress all the other sections.
 
Then Create a Shared Variable to capture the maximum date for the StartCode
 
Create a Formula for that.
 
Frm_SharedSt_codedate
WhilePrintingRecords;
Shared datevar StDate;
StDate := date({max_date.date})
Place the formula in suppress section above Group Header.
 
Then Insert the subreport in Main Report Group Header once done right click the subreport and change subreport links
 
Move(?ParameterStartCodename} to Fields to Link to  and Check the box
Select data in subreport based on field select the code from dropdown.
 
Then in subreport record selection formula check for the below code is created automatically if not  enter the code below
 
{table.codefieldname} = {?Pm-?StartCodefielname}
 
So you will get Maxdate for start code for the username ,
 
Then in main report you will need to create a formula to get the max date for start code
 
Create a formula
Frm_SharedStCodeDate
WhilePrintingRecords;
Shared datevar StDate;
Place this formula in Group Header or Footer .
 
 
once done to calculate diff in weeks use datediff
 
Create a formula
 
DiffInWeeks
DateDiff ("w",{@Frm_SharedStDate},{@Frm_SharedEndDate})
 
For give date the value for weeks is 1
 
Let me know how it goes,if you want I can mail you the report with your sample data
 
Cheers
Rahul
IP IP Logged
lrcrystaluser
Newbie
Newbie


Joined: 16 Feb 2009
Location: United Kingdom
Online Status: Offline
Posts: 10
Quote lrcrystaluser Replybullet Posted: 27 Feb 2009 at 6:29am
Hi Rahul,
First many thanks for your help. This is beyond anything I have done before and I am struggling with the sub report formula. What is {max_date.date}?
Keep on trying!
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: 27 Feb 2009 at 7:04am
Hi
 
That will be your {table.datefieldname}
 
Cheers
Rahul
IP IP Logged
lrcrystaluser
Newbie
Newbie


Joined: 16 Feb 2009
Location: United Kingdom
Online Status: Offline
Posts: 10
Quote lrcrystaluser Replybullet Posted: 27 Feb 2009 at 7:34am
that is what I thought but I am getting an error "A date time is required here."
Keep on trying!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 Feb 2009 at 8:06am
this must be a string rather than a date field
try converting it using the cdate function:
cdate({table.datefieldname})
IP IP Logged
lrcrystaluser
Newbie
Newbie


Joined: 16 Feb 2009
Location: United Kingdom
Online Status: Offline
Posts: 10
Quote lrcrystaluser Replybullet Posted: 27 Feb 2009 at 8:11am
it is a date field but I tried the cdate function anyway. Still the same error!
Keep on trying!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 Feb 2009 at 8:14am

just to check try cdatetime

IP IP Logged
lrcrystaluser
Newbie
Newbie


Joined: 16 Feb 2009
Location: United Kingdom
Online Status: Offline
Posts: 10
Quote lrcrystaluser Replybullet Posted: 27 Feb 2009 at 8:18am
I had to change the variable to a datetimevar but that has got rid of the error. Thank you!
Keep on trying!
IP IP Logged
<< Prev Page  of 2
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.016 seconds.