Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I generate a random number that is based on the date and time?

Tips and Tricks

How can I generate a random number that is based on the date and time?

by  Michael42  Posted    (Edited  )
Function Date2Number()
[color green]/*
Requires SET CENTURY ON
Returns 14 digit number that is always unique
*/[/color]
local nDate := 0
nDate = val( substr(dtoc(date()),7,4) + substr( dtoc( date() ),1,2) + substr( dtoc( date() ),4,2) + substr(time(),1,2) + substr(time(),4,2) + substr(time(),7,2) )
Return (nDate)
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top