Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Please help!! Urgent Post Reply Post New Topic
Author Message
albert
Newbie
Newbie


Joined: 16 Nov 2010
Online Status: Offline
Posts: 5
Quote albert Replybullet Topic: Please help!! Urgent
    Posted: 16 Nov 2010 at 6:04am

Hi there, I use Crystal Reports XI. I have a question and need somebody help me. 

I have to compare the dates (If under the same ID) to determine whether they can be combined to be one record or not. For example:

ID

Date1

Date2

1111111

11/14/2007

11/23/2007

1111111

12/4/2007

12/11/2007

1111111

12/14/2007

12/23/2007

 

The IDs on the above table are the same. If the different of the second record’s date2 and the third record’s date1 is equal or within 3 days, we combine these two records.

Final result after combined second and third record:   

1111111

12/4/2007

12/23/2007

However, in the following situation, my formula is not working.

ID

Date1

Date2

1111111

11/9/2007

 11/13/2007

1111111

11/9/2007

 11/18/2007

1111111

11/16/2007

 11/25/2007

My Result (Incorrect):

        ID            Date1              Date2

1111111

11/16/2007

11/25/2007

 

The correct result should be: (Which is combined these 3 records into one)

        ID              Date1            Date2

1111111

11/9/2007

11/25/2007

 

My formula for the Date1 is :

if RecordNumber = 1 then

        Date1

else if ClientID = previous(ClientID) and

            OrgID = previous(OrgID) and

            DateDiff("d", previous(Date2), Date1) <= 3 and

            previous(Date1) >= Date1 then

                Date1

else if ClientID = previous(ClientID) and

            OrgID = previous(OrgID) and

            DateDiff("d", previous(Date2), Date1) <= 3 and

            previous(Date1) < Date1 then

                previous(Date1)

   else if ClientID = previous(ClientID) and

            OrgID = previous(OrgID) and

            Date1 = previous(Date1) and

            Previous(Date2) < Date2 then

                Date1

    else if ClientID = previous(ClientID) and

            OrgID = previous(OrgID) and

            Date1 = previous(Date1) and

            Previous(Date2) >= Date2 then

                previous(Date1)

 

    else if ClientID = previous(ClientID) and

            OrgID = previous(OrgID) and

            Date1 < previous(Date1) and

            Previous(Date2) < Date2 then

                Date1

    else if ClientID = previous(ClientID) and

            OrgID = previous(OrgID) and

            Date1 < previous(Date1) and

            Previous(Date2) >= Date2 then

                Date1  

    else

         Date1

 

My formula for the Date2 is :

        Previous(Date2) <= Date2 then

            Date2

else if ClientID = previous(ClientID) and

        OrgID = previous(OrgID) and

        Date1 = previous(Date1) and

        Previous(Date2) > Date2 then

            Previous(Date2)

 

else if ClientID = previous(ClientID) and

        OrgID = previous(OrgID) and

        Date1 < previous(Date1) and

        Previous(Date2) <= Date2 then

            Date2

 

else if ClientID = previous(ClientID) and

        OrgID = previous(OrgID) and

        Date1 < previous(Date1) and

        Previous(Date2) > Date2 then

            Previous(Date2)      

else

    Date2

Could you please help me out? Thank you so much.
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.016 seconds.