### Using ranges in formulas

There are twenty-seven functions in Seagate Crystal Reports that specify date ranges. For example, the function LastFullMonth specifies a range of date values that includes all dates from the first to last day of the previous month. So if today's date is September 15, 1999 then LastFullMonth is the same as the range value CDate (#Aug 1, 1999#) To CDate (#Aug 31, 1999#).

Ranges are often used with If or Select expressions. The following example computes student letter grades based on their test scores. Scores greater than or equal to 90 receive an "A", scores from 80 to 90, not including 90, receive a "B" and so on.

    //Compute student letter grades
    Select {Student.Test Scores}
       Case UpFrom 90 :
          "A"
       Case 80 To_ 90 :
          "B"
       Case 70 To_ 80 :
          "C"
       Case 60 To_ 70 :
          "D"
       Default :
          "F";

The above example uses the Select expression which is discussed in more detail in the control structures section. You can check if a value is in a range by using the In operator. For example:

    5 In 2 To 10; //True
    5 In 2 To_ 5; //False
    5 In 2 To 5; //True

The Maximum and Minimum functions can be used to find the endpoints of a range:

`Maximum (2 To 10) //Returns 10`

Seagate Software, Inc. http://www.seagatesoftware.com Please send comments to: techpubs@seagatesoftware.com