Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Calculating a month via a paramater Post Reply Post New Topic
Author Message
twinkle
Newbie
Newbie
Avatar

Joined: 16 Jun 2008
Location: United Kingdom
Online Status: Offline
Posts: 32
Quote twinkle Replybullet Topic: Calculating a month via a paramater
    Posted: 18 Dec 2008 at 8:54am
Hi,
 
I am trying to create a formula that calulates the reporting month, but when i get to month 12 i get an error saying that there is no 13th month! The formula i am using is:
{Command.oppo_TargetClose} >= Cdate(2008,cdbl({?Report Month })+1,01)
(the parameter is set as a string.)
 
I know that i have to create a loop! to say when i get to month 13 then go to month 1 and add the new respective year to it  i.e jan 09.  otherwise just add 1 to the month.
 
Please help
Confused
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Dec 2008 at 8:43am
Can you use the DateAdd function here?
The DateAdd function will handle moving it to the next year without having to loop anything.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 19 Dec 2008 at 1:31pm
You don't need a loop, just an If statement.  Something like this:
If (cdbl({?Report Month}) = 12) then
  {command.oppo_TargetClose} >= Cdate(2009, 1, 1)
else
  {command.oppo_TargetClose} >= Cdate(2008, cdbl({?Report Month}) + 1, 01)
 
There are some other things you can do to dynamically set the year if you don't want to hard-code this report for this year.  It would look something like this:
if ({?Report Month}) = 12 then
  {Command.oppo_TargetClose} >= CDate(year(CurrentDate) + 1, 1, 1)
else
  {Command.oppo_TargetClose} >= CDate(year(CurrentDate), cdbl({?Report Month}) , 1)
 
-Dell
 
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.031 seconds.