Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: date difference/comparison within several details Post Reply Post New Topic
Page  of 3 Next >>
Author Message
flanman
Senior Member
Senior Member
Avatar

Joined: 04 Nov 2009
Online Status: Offline
Posts: 123
Quote flanman Replybullet Topic: date difference/comparison within several details
    Posted: 02 Mar 2010 at 11:07am
I have a report where I  am pulling a list of events by company within a 90 day time frame. Some companies have several events in the details section. One of the fields I am pulling is a date field. I need to create a formula that compares each of the dates in the detail field and if the difference is less that 56 days I need to see that date. Something like this.

Company 1
     Event1                         Jan 05, 2010
     Event2                         Feb 18, 2010
     Event3                         March 24, 2010

Company 2
     Event 1                       Jan 01, 2010
     Event 2                       Mar 15, 2020

I already have a preset 90 day range or pulling the initial dates.
The filter I would create would compare Company 1 Event1 date to Event2 date, and Event 2 Date to Event 3 Date and if any are within 56 days show those items.
Based on the filter Co. Company 2 would not show as the dates are more than 56 days apart.
Hopefully that all makes sense.

Flanman




IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 02 Mar 2010 at 11:14am
If you moved the Company to the group footer you can do it without subreports. You also need to decide how you are handling your last row in the group.
IP IP Logged
flanman
Senior Member
Senior Member
Avatar

Joined: 04 Nov 2009
Online Status: Offline
Posts: 123
Quote flanman Replybullet Posted: 02 Mar 2010 at 11:31am
Moving Company to group footer is fine, but not sure what you mean by handling the last row in the group. I want to compare all dates so if there are 2 dates then just those two. If there are multiple dates then date1 to date2, date2 to date3, date3 to date4 etc. The dates are already in chronological order so I don't need to compare date1 to date3 etc. But I am lost on how to even create the formula to do the comparison.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 02 Mar 2010 at 11:39am
You can use the NEXT() to do a comparison inside a Running Total. 

What I mean by the last row is that it never has a next value to compare to so it will never be withing the 56 days. Unless you want all details suppressed or if you want both rows that have < 56 days shown.

Group on the Company Name

Create a RT as "DayCount"

Field to Summarize=Comapny Name
Type of Summary= DistinctCount
Evaluate=Use a Formula
next(table.companyname)=table.companyname and
datediff('d',table.date,next(table.date))<56

Reset=On change of group (company name group)

Place on GF1 you will see the value of 1 when there is at least one row that meets your 56 day event

Edited by DBlank - 02 Mar 2010 at 11:40am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 02 Mar 2010 at 11:43am
YOu can then use this RT for suppression condition on teh footer. Note it won't suppress your header because the RT does not work in a header.
IP IP Logged
flanman
Senior Member
Senior Member
Avatar

Joined: 04 Nov 2009
Online Status: Offline
Posts: 123
Quote flanman Replybullet Posted: 02 Mar 2010 at 11:52am
Ok. I am trying that, but I am getting a syntax error. Based on what you have above my formula for the RT is:
next{Accounts.Name} = Accounts.Name and
datediff('d',DriveMaster.FromDateTime,next{DriveMaster.FromDateTime})<56

but I am getting the error "The remaining text does not appear to be part of the formula??

btw. Thanks for the help.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 02 Mar 2010 at 11:55am
You have to parenth around the NEXT function...Next(table.field) ... and around the Datediff...Datediff('d',startdate, enddate)...
datediff('d',DriveMaster.FromDateTime,next({DriveMaster.FromDateTime}))<56


Edited by DBlank - 02 Mar 2010 at 11:55am
IP IP Logged
flanman
Senior Member
Senior Member
Avatar

Joined: 04 Nov 2009
Online Status: Offline
Posts: 123
Quote flanman Replybullet Posted: 02 Mar 2010 at 11:56am
I got it.

next({Accounts.Name}) = {Accounts.Name} and
datediff('d',{DriveMaster.FromDateTime},next({DriveMaster.FromDateTime}))<56;

Working now. Thanks again.
IP IP Logged
benner
Newbie
Newbie


Joined: 18 Mar 2010
Online Status: Offline
Posts: 23
Quote benner Replybullet Posted: 18 Mar 2010 at 5:51am
I am trying to calculate a similar formula.  Difference between two date fields.  I used the same formula in this thread.  I get an error  of "A date is required here".  Any ideas on how to fix this?
 
Thank you
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 18 Mar 2010 at 6:07am

1. What are your field types for every value inthe formula?

2. what is the formula?
 
3. what are you trying to do with the the formula?
 
IP IP Logged
Page  of 3 Next >>
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.