Tips and Tricks
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Tips and Tricks
Message Icon Topic: Periodo calculado Post Reply Post New Topic
Author Message
carine
Newbie
Newbie


Joined: 27 Jun 2013
Location: Brazil
Online Status: Offline
Posts: 14
Quote carine Replybullet Topic: Periodo calculado
    Posted: 27 Jun 2013 at 7:38am
Good afternoon!

I am having difficulties in a crystal report and I hope you can help me.! hehe

I have the field "Period" type numeric. Example = 201306
it is the year and month along as you can see.
This field will filter the report, I need to create a formula that when the user enter the "Period" it shows the previous twelve months.
Example user enters 201306 the report shows:

201305 201304 201303 201302 201301 201212 201211 201210 201209
201208 201207 201206

how to do it? another and how do I get the data that have to be the same for the months?
IP IP Logged
praveeng
Senior Member
Senior Member
Avatar

Joined: 11 Jul 2011
Online Status: Offline
Posts: 165
Quote praveeng Replybullet Posted: 28 Jun 2013 at 6:11am
Hi Carine,
 
Use the below formula to show the previous 12 months
 
Numbervar Yr :=ToNumber(Left({?My Parameter},4));
NumberVar Mn :=ToNumber(Right({?My Parameter},2));
Numbervar i:=0;
Datevar dt:= Cdate(Yr,Mn,1);
StringVar tt:="" ;
for i :=1 to 12 do
tt:= tt+ Totext(Year(dateadd("m",-i, dt)),0)&Totext(Month((dateadd("m",-i, dt))),0)+CHR(32);
tt;
 
 
P.S: Replace the {?My Parameter} field with your YearMonth input field.
The above formula will shows all the previous YearMonth values in a single Text box,
if you want to treat those values as separete then you need to load those values to an Array based on Space(chr(32)) value.
Praveen Guntuka,
praveen_guntuka@yahoo.com
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.