ASP Functional Library (2)

Source: Internet
Author: User
function Array ()


FUNCTION: Returns an array


Syntax:array (list)


ARGUMENTS: Characters, numbers can be


EXAMPLE: <%


Dim myarray ()


for i = 1 to 7


Redim Preserve myarray (i)


myarray (i) = WeekdayName (i)


Next


%>


Result: An array containing 7 elements was created MyArray


myarray ("Sunday", "Monday", ...) "Saturday")


 


CInt ()


FUNCTION: Converts an expression to a numeric type


syntax:cint (expression)


ARGUMENTS: Any valid character can be


EXAMPLE: <%


f = "234"


Response.Write CINT (f) + 2


%>


result:236


converts the character "234" to the number "234" and returns a value of 0 if the string is empty


 


CreateObject ()


FUNCTION: Establishes and returns an instance of a registered ActiveX component.


Syntax:createobject (objname)


Arguments:objname is the name of any valid, registered ActiveX component.


EXAMPLE: <%


Set con = Server.CreateObject ("ADODB.") Connection ")


%>


Result:


 


CStr ()


FUNCTION: Converts an expression to a string.


syntax:cstr (expression)


Arguments:expression is any valid expression.


EXAMPLE: <%


s = 3 + 2


Response.Write "The result is:" & CStr (s)


%>


Result: Converts the number "5" to the character "5".


 


Date ()


FUNCTION: Returns the current system date.


syntax:date ()


Arguments:none.


EXAMPLE: <%=Date%>


result:8/4/99


 


DateAdd ()


FUNCTION: Returns a date that has been changed.


Syntax:dateadd (timeinterval,number,date)


Arguments:timeinterval is the time interval to add; Number is amount of


time intervals to add; And date is the starting date.


EXAMPLE: <%


currentdate = #8/4/99#


newdate = DateAdd ("M", 3,currentdate)


Response.Write Newdate


%>


  


<%


currentdate = #12:34:45 pm#


newdate = DATEADD ("h", 3,currentdate)


Response.Write Newdate


%>


result:11/4/99


3:34:45 PM


  


"M" = "month";


"D" = "Day";


  


If currentdate is in the time format then,


"H" = "Hour";


"S" = "second";


 


DateDiff ()


FUNCTION: Returns the difference between two dates.


Syntax:datediff (Timeinterval,date1,date2 [, FirstDayOfWeek] [,


FirstWeekOfYear]])


Arguments:timeinterval represents a type of time between intervals, such as "M" for "month."


EXAMPLE: <%


FromDate = #8/4/99#


toDate = #1/1/2000#


Response.Write "There are" & _


DateDiff ("D", Fromdate,todate) & _


"Millenium from 8/4/99."


%>


Result: There are 150 days from 8/4/99 to 2000.


 


Day ()


FUNCTION: Returns the day ordinal of a one-month period.


syntax:day (date)


Arguments:date is any valid date.


EXAMPLE: <%=day (#8/4/99#)%>


Result:4





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.