Outputs a random number with date format. asp

Source: Internet
Author: User
Tags format expression integer

<%
Function Getrannum ()
'****************************************
' Function name: getrannum
' Function: output random number with date format
' Parameter: no----
' Return value: such as Getrannum (), that is, output 200409071553464617, September 07, 2004 15:53 46 seconds 4617 Random number
' Association function: Formatintnumber
'****************************************
Getrannum = ""
Getrannum = Getrannum&formatintnumber (year (now), 4)
Getrannum = Getrannum&formatintnumber (Month (now), 2)
Getrannum = Getrannum&formatintnumber (Day (now), 2)
Getrannum = Getrannum&formatintnumber (Hour (now), 2)
Getrannum = Getrannum&formatintnumber (Minute (now), 2)
Getrannum = Getrannum&formatintnumber (second (now), 2)
Randomize
Rannum=int ((9000*rnd) +1000)
Getrannum = Getrannum&rannum
End Function
Function Formatintnumber (Expression,digit)
'****************************************
' Function name: Formatintnumber
' Function: output digit bit left with 0 integer
' Parameters: Expression----to format integers
' Parameters: Digit----To format the number of digits
' Return value: such as 0005, such as Formatintnumber (5,4), integer 5 is formatted as 0005
' Association function: None
'****************************************
While Len (Expression) < Digit
Expression = "0" &expression
Wend
Formatintnumber = Expression
End Function
%><%
Function Getrannum ()
'****************************************
' Function name: getrannum
' Function: output random number with date format
' Parameter: no----
' Return value: such as Getrannum (), that is, output 200409071553464617, September 07, 2004 15:53 46 seconds 4617 Random number
' Association function: Formatintnumber
'****************************************
Getrannum = ""
Getrannum = Getrannum&formatintnumber (year (now), 4)
Getrannum = Getrannum&formatintnumber (Month (now), 2)
Getrannum = Getrannum&formatintnumber (Day (now), 2)
Getrannum = Getrannum&formatintnumber (Hour (now), 2)
Getrannum = Getrannum&formatintnumber (Minute (now), 2)
Getrannum = Getrannum&formatintnumber (second (now), 2)
Randomize
Rannum=int ((9000*rnd) +1000)
Getrannum = Getrannum&rannum
End Function
Function Formatintnumber (Expression,digit)
'****************************************
' Function name: Formatintnumber
' Function: output digit bit left with 0 integer
' Parameters: Expression----to format integers
' Parameters: Digit----To format the number of digits
' Return value: such as 0005, such as Formatintnumber (5,4), integer 5 is formatted as 0005
' Association function: None
'****************************************
While Len (Expression) < Digit
Expression = "0" &expression
Wend
Formatintnumber = Expression
End Function
%>

Turn from: Dynamic Network production guide www.knowsky.com

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.