Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Date compare current year to last year Post Reply Post New Topic
Author Message
STCPD
Newbie
Newbie
Avatar

Joined: 08 Jun 2012
Online Status: Offline
Posts: 18
Quote STCPD Replybullet Topic: Date compare current year to last year
     Posted: 27 Mar 2013 at 5:25am
I need to compare data during the same time period but from diffrent years.
Example: I'm pulling data for burglaries from 1/1/2013 - 3/31/2013 using this running total.
 
{lwchrg.ucr_code}="220" AND {lwmain.zone} IN ["Z1","Z2","Z3","Z4","Z5","Z6","Z7","Z8"]AND
{lwmain.date_rept}>={?START DATE} AND {lwmain.date_rept}<={?END DATE}
 
Works good. No problem there but now I need to pull all the buglaries from the same 1/1 - 3/31 range but from 2012. I created another running total and tried this formula but it's not working.
 
{lwchrg.ucr_code}="220" AND {lwmain.zone} IN ["Z1","Z2","Z3","Z4","Z5","Z6","Z7","Z8"] AND
{lwmain.date_rept} >= DATEADD("yyyy",-DATEDIFF("yyyy",{?START DATE},{?END DATE}),{?START DATE}) AND
{lwmain.date_rept}<= {?START DATE}
 
Help please!
Thanks!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 Mar 2013 at 5:30am
first you need to make sure your select statemtn does not exlcude the data
second I assume your 'Running Total' is an evaluate formula inside a RT:
 
{lwchrg.ucr_code}="220" AND {lwmain.zone} IN ["Z1","Z2","Z3","Z4","Z5","Z6","Z7","Z8"] AND
{lwmain.date_rept} in dateadd('yyyy',-1,{?START DATE}) to dateadd('yyyy',-1,{?END DATE})
IP IP Logged
STCPD
Newbie
Newbie
Avatar

Joined: 08 Jun 2012
Online Status: Offline
Posts: 18
Quote STCPD Replybullet Posted: 27 Mar 2013 at 6:24am
Here is my select satement in the record selection of selection formulas:
{lwmain.date_rept}>={?START DATE}
AND
{lwmain.date_rept}<={?END DATE}
So I guess it is excluding the data that are not within my parameter dates. Any idea how I fix this?
Thanks for your help!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 Mar 2013 at 6:38am
{lwmain.date_rept} in {?START DATE} to {?END DATE}
or
{lwmain.date_rept} in dateadd('yyyy',-1,{?START DATE}) to dateadd('yyyy',-1,{?END DATE})
IP IP Logged
STCPD
Newbie
Newbie
Avatar

Joined: 08 Jun 2012
Online Status: Offline
Posts: 18
Quote STCPD Replybullet Posted: 27 Mar 2013 at 6:45am
Perfect!!!! Thank you so much for your help!Clap
IP IP Logged
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