Crystal Reports- displaying calculations for date range prior to date search parameter

15 pts.
Tags:
Crystal Reports XI
I'm working on a formula to calculate the number of criminal offenses that occurred in the same amount of days as my date search parameter but prior to the start date. The date search parameter is always changing. The idea is to compare the number of offenses from the last time period. I want to use the same report wheather it's for a year, months, weeks or days.

For instance say my date search parameter is 5/1/2012 to 5/31/2012.

I can get the number of offenses easily by using:

{lwchrg.ucr_code}="23F" AND {lwmain.zone} IN ["Z1","Z2","Z3","Z4","Z5","Z6","Z7","Z8">

But I'm having trouble with the prior date portion.

This got me the number of days in the search parameter which in this example would be 30.                                                                   

numberVar days :=DateDiff ("d",{?START DATE} , {?END DATE})

This got me the start date that I was looking for which in this example would be 4/1/2012:

DateAdd ("d",-numberVar days :=DateDiff ("d",{?START DATE} , {?END DATE}) ,{?START DATE} )

So I came up with this but it is not working. I get an error that says the formula cannot be a range.

DateAdd ("d",-numberVar days :=DateDiff ("d",{?START DATE} , {?END DATE}) ,{?START DATE} ) to dateadd ("d",-1,{?START DATE})

Help please!



Software/Hardware used:
Crystal Reports 2011

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following