Page 1 of 1

Random Number Generator

Posted: Thu Dec 12, 2013 10:24 am
by brentbond
Hi. Is there a way in Custom Reports (in Accounts Payable) to generate a random number (preferably a 3 digit number)? I have tried using SYS(2015) but that generates a much longer (like 9 charachters) alphanumeric character string where I would like a 3 digit numeric.

Thanks for any help you can provide.


----- Brent -----

Re: Random Number Generator

Posted: Thu Dec 12, 2013 1:09 pm
by Zorak
Unfortunately, there isn't a truly random number function. RAND() returns a predetermined chain of "random" numbers. Every time you run PowerChurch, it would start that same chain of numbers over again.

Code: Select all

TRANSFORM(CEILING(RAND()*1000),'@L 999')
So, here's the best that we can come up with in a single expression:

Code: Select all

TRANSFORM(CEILING(RAND(SECONDS()+CEILING(RAND()*1000))*1000),'@L 999')
That is ridiculous and still isn't truly random for more than a day, but it's based on the number of milliseconds since midnight each day, so it's probably close enough. Also, it is possible that these could return a one or two digit number, so the numbers are formatted to include leading zeros (001,011) if necessary.