Print Page | Close Window

Periodo calculado

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Tips and Tricks
Forum Discription: Have you learned some great tricks to share with the group? Post them here!
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=19720
Printed Date: 14 May 2024 at 3:24pm


Topic: Periodo calculado
Posted By: carine
Subject: Periodo calculado
Date 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?



Replies:
Posted By: praveeng
Date 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



Print Page | Close Window