Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Help! Report Avg DateDiff by Month Post Reply Post New Topic
Author Message
reportwriter
Newbie
Newbie
Avatar

Joined: 09 Nov 2007
Location: United States
Online Status: Offline
Posts: 2
Quote reportwriter Replybullet Topic: Help! Report Avg DateDiff by Month
    Posted: 13 Nov 2007 at 5:07am

How would I calculate and report the average difference in the number of days (between the beginning and end dates) by Month?  Data is averaged and reported by the end_date's month.

If I have this type of data:

begin_date   end_date
1/14/2007    2/6/2007
2/1/2007      4/2/2007
2/1/2007      2/28/2007
3/1/2007      3/25/2007

The difference “in days” for each record and the reporting month are:
Record 1            23            reported in “Feb”
Record 2            60            reported in “Apr”
Record 3            27            reported in “Feb”
Record 4            24            reported in “Mar”

The result of the crystal report should be:

Jan    Feb    Mar    Apr
0        25      24     60

I am new to Crystal Reports and pseudo code would help me get started.

Thank you for your help!

Pat

 

Pat
IP IP Logged
jkwrpc
Senior Member
Senior Member


Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet Posted: 13 Nov 2007 at 11:31am
You could use the DateDiff function to calculate the days between the dates.
 
From CR Help under functions DateDiff
___________________________

The following examples are applicable to both Basic and Crystal syntax:

Use DateDiff with the "d" or "y" interval type parameter to find the number of days between two dates:

DateDiff ("d", #10/7/1999#, #10/10/1999#)

Returns 3.

_____________________________________
 
You could also use DatePart to parse the month from the end date.
Again from CR Help
________________________

DatePart ("m", #August 15, 1999#)

Returns 8.

DatePart ("m", #August 15, 1999#)

Returns 8.

_____________________
 
You could then convert the number to text in a formula.
 
What will be a bit problematic is getting your left to right layout. You will need to create a formuals for each month.
 
Hope this helps.
 
Regards,
 
John W.
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.047 seconds.