Random Number Generator

Moderators: Moderators, Tech Support

Post Reply
brentbond
Posts: 49
Joined: Sat Sep 04, 2010 4:12 pm

Random Number Generator

Post 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 -----

Zorak
Tech Support
Tech Support
Posts: 3006
Joined: Thu May 13, 2004 9:59 am
Location: PowerChurch Software
Contact:

Re: Random Number Generator

Post 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.

Post Reply