[thelist] generating an order #

Keith cache at dowebscentral.com
Tue Jan 7 04:30:01 CST 2003


At 11:22 PM Monday 1/6/2003, Anthony wrote:

>Function UniqueID_Time()
>     Randomize Right(ABS(DateDiff("s",Now,#1/1/1998#)),4)
>     nBaseID = Right(Abs(DateDiff("s",Now,#1/1/1998#)),8)
>     UniqueID_Time = Right(Year(now),2) & Numeric_Pad(Month(now)) _
>         & "-" & Left(nBaseID,2) & "-" & Mid(nBaseID,3,3) _
>         & "-" & Right(nBaseID,3) & "-" & Int((998 - 101 + 1) * Rnd + 101)
>End Function
>Function Numeric_Pad(varNumber)
>     if (Int(varNumber) < 10) then
>         varNumber = "0" & varNumber
>     end if
>     Numeric_Pad = varNumber
>End Function
>This could return an order number like this: 0301-58-246-279-369

I don't know, I guess I'm just incredibly lazy. I like to use & store the
time stamp - that way I can later convert it into any date display I might
want at that time.
$trans_id=reverse(time);
will produce a number like
8541391401

As for dashes, I'd rather have the guy thinkin' I've had 8541391401
satisfied customers.

BTW, you may want to rethink your random number. If it works like most
rands it's generated from the Era time stamp, as was the rest of your calc.
In otherwords, the other guy that submitted at exactly the same second will
have the exact same random number. For that reason I strip 0s,1s & dots
from the customer's remote_addr and append the remainder. Even if you seed
the rand, the seed better not be time based or you'll still get exact matches.



Keith
====================
cache at dowebscentral.com




More information about the thelist mailing list