I have a formula which has following code
if {@number of days}<=120
then
'0-120'
else if {@number of days} >120 and{@number of days} <=150
then '121 - 150'
else if {@number of days} >150 and{@number of days} <=180
then '151 - 180'
else if {@number of days} >180 and{@number of days} <=210
then '181 - 210'
else if {@number of days} >210 and{@number of days} <=240
then '211 - 240'
else if {@number of days} >240 and{@number of days} <=270
then '241 - 270'
else if {@number of days} >270 and{@number of days} <=300
then '271 - 300'
else if {@number of days} >300 and{@number of days} <=330
then '301 - 330'
else if {@number of days} >330 and{@number of days} <=360
then '331 - 360'
else if {@number of days} >360 and{@number of days} <=390
then '361 - 390'
else if {@number of days} >390 and{@number of days} <=420
then '391 - 420'
.....
Can I write a small code so that I don't need to write too many if else statement? The code will increment the vale for each 30 days after 120 days.
ANy help will be appreciated.
I was trying to write something like
numbervar x:=0;
numbervar y:=120;
stringvar str;
numbervar i=0;
for i:=120 to 3651 do
if y<=120 then
str:=totext(x)+'to'+totext
else
x:=y+1;
y:=y+30;
str:=totext(x)+'to'+totext;
i:=i+30;
str
Not sure how to hold previous value, so my code did not work properly.
Thanks,
bubu
if {@number of days}<=120
then
'0-120'
else if {@number of days} >120 and{@number of days} <=150
then '121 - 150'
else if {@number of days} >150 and{@number of days} <=180
then '151 - 180'
else if {@number of days} >180 and{@number of days} <=210
then '181 - 210'
else if {@number of days} >210 and{@number of days} <=240
then '211 - 240'
else if {@number of days} >240 and{@number of days} <=270
then '241 - 270'
else if {@number of days} >270 and{@number of days} <=300
then '271 - 300'
else if {@number of days} >300 and{@number of days} <=330
then '301 - 330'
else if {@number of days} >330 and{@number of days} <=360
then '331 - 360'
else if {@number of days} >360 and{@number of days} <=390
then '361 - 390'
else if {@number of days} >390 and{@number of days} <=420
then '391 - 420'
.....
Can I write a small code so that I don't need to write too many if else statement? The code will increment the vale for each 30 days after 120 days.
ANy help will be appreciated.
I was trying to write something like
numbervar x:=0;
numbervar y:=120;
stringvar str;
numbervar i=0;
for i:=120 to 3651 do
if y<=120 then
str:=totext(x)+'to'+totext
else
x:=y+1;
y:=y+30;
str:=totext(x)+'to'+totext;
i:=i+30;
str
Not sure how to hold previous value, so my code did not work properly.
Thanks,
bubu