Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sloppy Formula?

Status
Not open for further replies.

MrTBC

Technical User
Nov 19, 2003
610
US
I have written the following formula for Selection Criteria which works, but would be interested to know for future reference if there would be a shorter and cleaner way of achieving this.

Many Thanks.

numberVar x := CDbl({?Year});
numberVar y := x+1;

select {?Period}
Case "1" : {MATDB.DATE-OPENED} in Date (x, 05, 01) to Date (x, 05, 31)
Case "2" : {MATDB.DATE-OPENED} in Date (x, 05, 01) to Date (x, 06, 30)
Case "3" : {MATDB.DATE-OPENED} in Date (x, 05, 01) to Date (x, 07, 31)
Case "4" : {MATDB.DATE-OPENED} in Date (x, 05, 01) to Date (x, 08, 31)
Case "5" : {MATDB.DATE-OPENED} in Date (x, 05, 01) to Date (x, 09, 30)
Case "6" : {MATDB.DATE-OPENED} in Date (x, 05, 01) to Date (x, 10, 31)
Case "7" : {MATDB.DATE-OPENED} in Date (x, 05, 01) to Date (y, 11, 30)
Case "8" : {MATDB.DATE-OPENED} in Date (x, 05, 01) to Date (x, 12, 31)
Case "9" : {MATDB.DATE-OPENED} in Date (x, 05, 01) to Date (y, 01, 31)
Case "10" : {MATDB.DATE-OPENED} in Date (x, 05, 01) to Date (y, 02, 29)
Case "11" : {MATDB.DATE-OPENED} in Date (x, 05, 01) to Date (y, 03, 31)
Case "12" : {MATDB.DATE-OPENED} in Date (x, 05, 01) to Date (y, 04, 30)
 
I don't think this can be done in a more text-efficient way because there is no patern in your case statements. If there is you can create loops with increasing numbers so you can do a
'for i=1 to x do: '
And then increase your variables. In this case the variables dont show a patern so you will have to define them all seperately as you did.

Tanja

 
Here's one using Crystal Syntax. If I understand yours correctly, the report needs a starting year and then a numer of periods (months).

{@date} in date({?year},5,1) to dateadd ("m",{?period},date({?year},5,1))-1



Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top