Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Change Month based on Current date Post Reply Post New Topic
Author Message
Jesse
Newbie
Newbie


Joined: 05 Feb 2010
Online Status: Offline
Posts: 7
Quote Jesse Replybullet Topic: Change Month based on Current date
     Posted: 24 Jun 2010 at 9:28am
Hello,

I am trying to create a manual cross tab report to show sales data for each month of the year, rotating by whatever the current month is. For example:

Customer    June(Current)   May   April   March   Feb    Jan   Dec
Cust A          $$$                  $$$   $$$    $$$      $$$   $$$   $$$

The Fiscal Period field I am using is a string field of 2 characters. Here is what my formula is so far:

if (tonumber ({AR_CustomerSalesHistory.FiscalPeriod})) = (Month(CurrentDate)) then {AR_CustomerSalesHistory.DollarsSold}

For each month going backward I use:
if (tonumber ({AR_CustomerSalesHistory.FiscalPeriod})) = (Month(CurrentDate)-1) then {AR_CustomerSalesHistory.DollarsSold}

This works up until I get to December because it is trying to subtract 6 from 6 giving a value of 0 which doesn't equate to any month.

I have tried several other methods of getting the same data out of this but can't quite seem to get the fields to match. I have tried DateSerial, CDate, and DateAdd. Again I think the problem is that I am not able to relate the string field Fiscal Period to any of these formula return types.

Any help would be much appreciated!!

Jesse


IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 24 Jun 2010 at 10:01am
I assume your fiscal period field is just a 2 digit text of 01 thru 12.
 
if (tonumber ({AR_CustomerSalesHistory.FiscalPeriod})) = Month(dateadd('m',-6,CurrentDate)) then {AR_CustomerSalesHistory.DollarsSold}
IP IP Logged
Jesse
Newbie
Newbie


Joined: 05 Feb 2010
Online Status: Offline
Posts: 7
Quote Jesse Replybullet Posted: 24 Jun 2010 at 10:17am
This worked perfectly! Thanks so much for the help.

Jesse
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