Tips and Tricks
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Tips and Tricks
Message Icon Topic: Date Minus a Year Post Reply Post New Topic
Author Message
Em123
Newbie
Newbie
Avatar

Joined: 28 Jan 2012
Online Status: Offline
Posts: 1
Quote Em123 Replybullet Topic: Date Minus a Year
    Posted: 29 Jan 2012 at 12:19am
I am trying to compare transaction data between previous years and the current year. I am using tdate as the transaction date and I have two parameters called Start Date and End Date. How do I assign the following. (Using Crystal Syntax)
 
Start Date>= tdate - 1 year and End Date<= tdate - 1 year
 
The transaction data needs to be shown in two columns one for this year one for last year showing the sum per day. I will eventually either use a cross tab or possibly a group to do each day but need them split per year as well.
 
If possible I would like to match the day of this year to the same day of last year. E.g. Sunday 29th Jan 2012 would match up with Sunday 30th Jan 2012.
 
Any ideas much appreciated! Smile
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 29 Jan 2012 at 9:50pm

{?startdate} >= dateadd("yyyy",-1,{tdate})
and
{?enddate} <= dateadd("yyyy",-1,{tdate})
 
would replicate the formula above.
 

{?startdate} >= dateadd("ww",-52,{tdate})
and
{?enddate} <= dateadd("ww",-52,{tdate})
 
Would return the same day of the week a year ago.
 
 
However I assume your startdate occurs before your enddate? The above formulas wouldn't return any entries as you're asking for a return where the transaction date is before the startdate and after the enddate.
 
dateadd("ww",-52,{tdate})  >= {?startdate} 
and
dateadd("ww",-52,{tdate}) <= {?enddate}
 
Would return everything between the start and end date.
 
Regards,
Ryan.


Edited by rkrowland - 30 Jan 2012 at 12:08am
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.033 seconds.