RAND( ) function

Returns a random number between zero and the value of a numeric expression.

Syntax

RAND(number)

Parameters

number

Numeric. The maximum value of the random number.

Output

Numeric.

Remarks

RAND( ) returns a random number greater than or equal to 0 and less than the value in the number parameter. For example, the output of RAND(100) is a number from 0 to 99. It is possible for duplicate random numbers to be generated if the value in the number parameter is less than the number of records in the table. For example, if a table has 2000 records and you create a computed field using the expression RAND(1000), there will be duplicates in the output. The number parameter can be positive or negative and can include decimals. The random number generated has the same number of decimal places as the number parameter.

Note

Because expressions are evaluated whenever the table layout or the view changes, the RAND( ) function generates a new random number every time you perform actions such as applying a filter, rearranging columns, or simply scrolling through the view. To ensure that a random number does not change once it has been generated, extract the data to a new table using the View or Fields option in the Extract dialog box.

You can use this function to generate a random number for use in ACL or in another application.

Note

If you use the RAND( ) function consecutively with the same value, it produces different results. The sequence is not reseeded before ACL generates the second result. To reseed the sequence, use the RANDOM command.

Examples

Example Return value

RAND(1000.00)

278.61

RAND(10000)

3781



(C) 2013 ACL Services Ltd. All Rights Reserved. | Send feedback