Asp Built in Functions: Purpose: Datatype: Syntax: Arguments: Sample: Result
Asp Built in Functions: Purpose: Datatype: Syntax: Arguments: Sample: Result
ABS()
Purpose:
Returns the absolute value of a number
DataType:
The same as the number th
Syntax:
ABS(number)
Arguments:
"number" is any valid number. If NULL, then NULL is returned; if empty, then 0 is returned.
Sample:
response.write ABS(-193.24)
Result:
193.24
Array()
Purpose:
Returns an Array
DataType:
Array
Syntax:
Array(List)
Arguments:
"list" is a comma-delimited list of values to add to the array.
Sample:
Dim X
X = Array("Paul","Mike","Tom")
response.write X(2)
Result:
Array index always starts with "0" by default. So the total elements in an array would be
UBOUND(ArrayName) + 1
ASC()
Purpose:
Returns the integer that's representing the character
DataType:
Integer
Syntax:
ASC(char)
Arguments:
"char" is any valid string. If NULL or Empty, run-time error will occur.
Sample:
response.write ASC("A")
Result:
65
Comments:
Only the first character will be returned.
CHR()
Purpose:
Returns the string of a given character code
DataType:
String
Syntax:
Chr(number)
Arguments:
"number" is any valid character code. If NULL or Empty, run-time error will occur.
Sample:
response.write Chr(97)
Result:
a
CInt()
Purpose:
Converts a numeric expression to an integer.
DataType:
Integer
Syntax:
Cint(number)
Arguments:
"number" is any valid number
Sample:
response.write CInt(-97.54)
Result:
-98
Comments:
There is a range limitation for this function: -32,768 to 32,767. If any number beyond this range is
passed as argument, run-time error "Overflow" will occur. User INT() function instead.
CStr()
Purpose:
Returns an expression that has been converted to a String
DataType:
String
Syntax:
CStr(var)
Arguments:
"var" is any valid expression.
Sample:
response.write CStr(-97.54)
Result:
-97.54
Date()
Purpose:
Returns the current system date.
DataType:
Date/Time
Syntax:
Date
Sample:
response.write date
Result:
9/16/2010
Comments:
Date returned is the SERVER date, not your computer date.
DateAdd()
Purpose:
Returns a date to which a specific time interval has been added.
DataType:
Date/Time
Syntax:
DateAdd(timeinterval,number,date)
Arguments:
"timeinterval" is the time interval to add;
"number" is amount of time intervals to add;
"date" is the starting date.
Sample:
response.write DateAdd("h", 3, Now)
Result:
9/16/2010 3:47:23 PM
Comments:
Date/Time returned is the SERVER date/time, not your computer date/time. Refer to the time interval
table below for the argument.
Comments:
yyyy - Year, m - Month, d - Day, ww - week, n - Minute, q - Quarter, y - Day of Year, w - Weekday, h
- Hour, s - Second
DatePart()
Purpose:
Returns an integer that contains a specific part of a given date/time
DataType:
Integer
Syntax:
DatePart(timeinterval, date[,firstdayofweek[, firstweekofyear]])
Arguments:
"timeinterval" is the time interval to use;
"date" is any valid date/time expression;
"firstdayofweek" and "firstweekofyear" are optional values to specify the first day of the week and
first week of year.
Sample:
response.write "Current Month: " & DatePart("m", Now)
Result:
Current Month: 9
Comments:
yyyy - Year, m - Month, d - Day, ww - week, n - Minute, q - Quarter, y - Day of Year, w - Weekday, h
- Hour, s - Second
DateSerial()
Purpose:
Returns a date for a specific year, month and day
DataType:
Date
Syntax:
DateSerial(year, month, day)
Arguments:
"year" is any valid integer between 100 and 9999
"month" is any valid integer from 1 to 12
"day" is any valida integer between 1 to 31
Sample:
response.write DateSerial(Year(now) + 3, Month(Now), Day(Now))
Result:
9/16/2013
Comments:
For the year argument, values between 0 and 29 are interpreted as the years 2000–2029. Values
between 30 and 99 are interpreted as the years 1930–1999. For all other year arguments, use a four-
digit year (for example, 1800).
DateValue()
Purpose:
Returns a date
DataType:
Date
Syntax:
DateValue(date)
Arguments:
"date" is any valid expression
Sample:
response.write DateValue("October 12, 1971")
Result:
10/12/1971
Day()
Purpose:
Returns the integer representing the day value of a given date
DataType:
Integer
Syntax:
Day(date)
Arguments:
"date" is any valid expression
Sample:
response.write Day(now)
Result:
16
Fix()
Purpose:
Returns the integer part of a number
DataType:
Integer
Syntax:
Fix(number)
Arguments:
"number" is any valid number
Sample:
response.write Fix(-97.54)
Result:
-97
Comments:
The difference between Int and Fix is that if number is negative, Int returns the first negative integer
less than or equal to number, whereas Fix returns the first negative integer greater than or equal to
number. For example, Int converts -8.4 to -9, an
FormatCurrency()
Purpose:
Returns an expression formatted as a currency value.
DataType:
String
Syntax:
FormatCurrency(Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit]]]])
Arguments:
"Expression" is a valid numeric expression;
"Digit" is an optional numeric value used to indicate number of digits to the right of the decimal point;
FormatDateTime()
Purpose:
Returns an expression formatted as a date or time
DataType:
String
Syntax:
FormatDateTime(Date, [, NamedFormat])
Arguments:
"Date" is any valid date expression, and NamedFormat is an optional date/time constant.
Sample:
response.write FormatDateTime("08/4/99", vbLongDate)
Result:
Wednesday, August 04, 1999
FormatNumber()
Purpose:
Returns an expression formatted as a number
DataType:
String
Syntax:
FormatNumber(Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit]]]])
Arguments:
"Expression" is a valid numeric expression;
"Digit" is an optional numeric value used to indicate number of digits to the right of the decimal point;
FormatPercent()
Purpose:
Returns an expression formatted as a percent value with a trailing percent (%).
DataType:
String
Syntax:
FormatPercent(Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit]]]])
Arguments:
"Expression" is a valid numeric expression;
"Digit" is an optional numeric value used to indicate number of digits to the right of the decimal point;
Hour()
Purpose:
Returns a whole number representing the hour of the day between 0 and 23
DataType:
Integer
Syntax:
Hour(time)
Arguments:
"time" is any valid date/time expression
Sample:
response.write Hour(Now())
Result:
12
InStrRev()
Purpose:
Returns the numeric position of one string within another starting from the end of the string.
DataType:
Integer
Syntax:
InStrRev([start, ] strToBeSearched, strSearchFor [, compare])
Arguments:
"start" (optional) is the numeric position to start the string search;
"strToBeSearched" is the string expression to be searched;
"strSearchFor" is the string expression search value;"compare" (optional) is the value indicating the
comparison constant.
Sample:
response.write InStrRev("Keep Testing!", "e")
Result:
7
Comments:
The returned the integer is still the position from the first character of the string, even though you
search from the end.
Int()
Purpose:
Returns the integer part of a number
DataType:
Integer
Syntax:
Int(number)
Arguments:
"number" is any valid number
Sample:
response.write Int(-97.54)
Result:
-98
Comments:
The difference between Int and Fix is that if number is negative, Int returns the first negative integer
less than or equal to number, whereas Fix returns the first negative integer greater than or equal to
number. For example, Int converts -8.4 to -9, an
IsArray()
Purpose:
Returns a boolean whether a given expression is array or not
DataType:
Boolean
Syntax:
IsArray(varAnyThing)
Arguments:
"varAnyThing" is any expression
Sample:
response.write IsArray("white")
Result:
False
IsDate()
Purpose:
Returns a boolean whether a given expression is date or not.
DataType:
Boolean
Syntax:
IsDate(varAnyThing)
Arguments:
"varAnyThing" is any expression
Sample:
response.write IsDate("10/13/99")
Result:
True
IsEmpty()
Purpose:
Returns a boolean whether a given expression is Empty or not.
DataType:
Boolean
Syntax:
IsEmpty(varAnyThing)
Arguments:
"varAnyThing" is any expression
Sample:
response.write IsEmpty("a")
Result:
False
IsNull()
Purpose:
Returns a boolean whether a given expression is NULL or not.
DataType:
Boolean
Syntax:
IsNull(varAnyThing)
Arguments:
"varAnyThing" is any expression
Sample:
response.write IsNull("a")
Result:
False
IsNumeric()
Purpose:
Returns a boolean whether a given expression is Numeric or not.
DataType:
Boolean
Syntax:
IsNumeric(varAnyThing)
Arguments:
"varAnyThing" is any expression
Sample:
response.write IsNumeric("a")
Result:
False
IsObject()
Purpose:
Returns a boolean whether a given expression is Object or not.
DataType:
Boolean
Syntax:
IsObject(varAnyThing)
Arguments:
"varAnyThing" is any expression
Sample:
Set con = Server.CreateObject("ADODB.Connection")
response.write IsObject(con)
Result:
True
Join()
Purpose:
Returns a string created by joining the elements in an array
DataType:
String
Syntax:
Join(Array)
Arguments:
Array is any valid one-dimmensional array
Sample:
a = Array("White", "Yellow", "Red")
response.write Join(a, "-")
Result:
White-Yellow-Red
LBound()
Purpose:
Returns the base index value for a dimension of any array
DataType:
Integer
Syntax:
Lbound(Array)
Arguments:
Array is any valid array.
Sample:
a = Array("White", "Yellow", "Red")
response.write LBound(a)
Result:
0
LCase()
Purpose:
Returns a string that has been converted into lowercase characters.
DataType:
String
Syntax:
Lcase(String)
Arguments:
"String" is any valid string
Sample:
response.write LCase("This is A Test!")
Result:
this is a test!
Left()
Purpose:
Returns the number of characters from the left side of a string
DataType:
String
Syntax:
Left(String, Length)
Arguments:
"String" is any valid string; "length" is the number of characters to return.
Sample:
response.write Left("This is A Test!", 6)
Result:
This i
Len()
Purpose:
Returns the number of characters in a string or the number of bytes required to store a variable.
DataType:
Long
Syntax:
Len(String|varname)
Arguments:
"String" is any valid string; varName is any valid variable.
Sample:
response.write Len("This is A Test!")
Result:
15
LTrim()
Purpose:
Returns a string without leading spaces
DataType:
String
Syntax:
Ltrim(String)
Arguments:
"String is any valid string
Sample:
response.write """" & LTrim(" This is A Test! ") & """"
Result:
"This is A Test! "
Mid()
Purpose:
Returns a specified number of characters from a string
DataType:
String
Syntax:
Mid(string, start [, length])
Arguments:
"String" is any valid string;
"start" is the position to start with;
"length" is the the number pf characters to be returned.
Sample:
response.write Mid("This is a test", 6, 2)
Result:
is
Minute()
Purpose:
Returns the number of the minutes in current system time.
DataType:
Integer
Syntax:
Minute(time)
Arguments:
"time" is any valid time expression
Sample:
response.write minute(now)
Result:
58
Month()
Purpose:
Returns the number of the month of the year
DataType:
Integer
Syntax:
Month(date)
Arguments:
"date" is any valid date expression
Sample:
response.write Month(Now)
Result:
9
MonthName()
Purpose:
Returns the name of the month of the year
DataType:
String
Syntax:
MonthName(month, [, Abb])
Arguments:
"month" is the numeric representation for a given month;
Abb (optional) is a boolean value used to display month abbreviation. True will display the
abbreviated month name and False (default) will not show the abbreviation.
Sample:
response.write MonthName(Month(Now), True)
Result:
Sep
Now()
Purpose:
Returns the current system date and time
DataType:
Date/Time
Syntax:
Now
Sample:
response.write Now()
Result:
9/16/2010 12:59:48 PM
Replace()
Purpose:
Returns a string in which a specified sub-string has been replaced with another substring a specified
number of times.
DataType:
String
Syntax:
Replace(strToBeSearched, strSearchFor, strReplaceWith [, start [, count [, compare]]])
Arguments:
"strToBeSearched" is a string expression containing a sub-string to be replaced;
"strSearchFor" is the string expression to search for within strToBeSearched;
"strReplaceWith" is the string expression to replace sub-string strSearchFor;
"start" (optio
Sample:
response.write Replace("This is David.", "David", "John")
Result:
This is John.
RGB()
Purpose:
Returns a number representing an RGB color value.
DataType:
Long
Syntax:
RGB(red, green, blue)
Arguments:
all three arguments are the integer value (from 0 to 255) that represents the color value.
Sample:
response.write RGB(255, 10, 0)
Result:
2815
Right()
Purpose:
Returns a specified number of characters from the right side of a string.
DataType:
String
Syntax:
Right(string, length)
Arguments:
"string" is any valid string expression;
"length" is any valid numeric expression representing the number of characters to return.
Sample:
response.write Right("This is a test", 4)
Result:
test
Rnd()
Purpose:
Returns a random number.
DataType:
Single
Syntax:
Rnd [ (number) ]
Arguments:
"number" is any valid numeric expression
Sample:
Randomize()
response.write RND
Result:
0.647381
Comments:
RND returns a value greater or equal to 0 but smaller than 1. Use the following function to create a
random number in a given range:
Int((EndingNumber - StartingNumber + 1) * Rnd + StartingNumber)
Make sure to add Randomize() statement without an argu
Round()
Purpose:
Returns a number rounded to a specified number of decimal places.
DataType:
Long
Syntax:
Round (expression [, numRight])
Arguments:
"expression" is any valid numeric expression to be rounded;
"numRight" (optional) is any numeric expression used to indicate the number of digits to the right of
the decimal point
Sample:
response.write Round(443.323632, 3)
Result:
443.324
RTrim()
Purpose:
Returns a string without trailing spaces.
DataType:
String
Syntax:
Rtrim(String)
Arguments:
"string" is any valid string
Sample:
response.write """" & RTrim(" This is A Test! ") & """"
Result:
" This is A Test!"
Second()
Purpose:
Returns the current seconds value of the current system time
DataType:
Integer
Syntax:
Second(Time)
Arguments:
"time" is any valid time expression
Sample:
response.write Second(now)
Result:
49
Comments:
Refresh this page to see the seconds change.
Space()
Purpose:
Returns a String consisting of the specified number of spaces.
DataType:
String
Syntax:
Space(Number)
Arguments:
"number" is any integer
Sample:
response.write """" & Space(10) & """"
Result:
""
Comments:
There are actually 10 spaces created between the pair of quotation mark. However, you can't see it
because HTML truncates any multiple spaces to one. To see it, view the source of this page by right
click on your mouse.
Split()
Purpose:
Returns a zero-based, one-dimensional array containing a specified number of substrings.
DataType:
Array
Syntax:
Split(string [, delimiter[, count[, compare]]])
Arguments:
"string" is any valid string;
"delimiter" (optional) is the string character to be used to identify the substring; if missing, space is
used.
"count" (optional) is the number of substring to be returned. -1 is default which indicates all;
"compare" (op
Sample:
arrNew = Split("White, Yellow, Blue, Red", ",")
Result:
[obtained an array (arrNew) contains 4 elements]
Sqr()
Purpose:
Returns a Double specifying the square root of a number
DataType:
Double
Syntax:
Sqr(number)
Arguments:
"number is any valid numeric expression
Sample:
response.write Sqr(16)
Result:
4
strComp()
Purpose:
Returns an interger representing the result of string comparison.
DataType:
Integer
Syntax:
StrComp(string1, string2[, compare])
Arguments:
"string1" and "string2" are any valid string expression.;
"compare" (optional) specifies the type of comparision. Can be "vbUseCompareOption" (Default),
"vbBinaryCompare", "vbTextCompare", or "vbDatabaseCompare".
Sample:
response.write strComp("David", "Frank")
Result:
-1
Comments:
If string1 is less than string2, result is -1;
if string1 is equal to string2, result is 0;
if string1 is greater than string2, result is 1;
if any string is NULL, result is NULL.
String()
Purpose:
Returns a String containing a repeating character string of the length specified.
DataType:
String
Syntax:
String(number, character)
Arguments:
"number" is any valid integer;
"character" is the string to be repeated.
Sample:
response.write String(6, "*")
Result:
******
StrReverse()
Purpose:
Returns a string where the character order has been reversed.
DataType:
String
Syntax:
StrRevers(string)
Arguments:
"string" is any valid string
Sample:
response.write StrReverse("This is a test")
Result:
tset a si sihT
Time()
Purpose:
Returns the current system time
DataType:
Time
Syntax:
Time
Sample:
response.write Time
Result:
1:04:07 PM
TimeSerial()
Purpose:
Returns the time for a specific hour, minute, and second
DataType:
Time
Syntax:
TimeSerial(hour, minute, second)
Arguments:
"hour" is any interger from 0 to 23;
"minute" is any valid integer;
"second" is any valid integer.
Sample:
response.write TimeSerial(18, 35, 27)
Result:
6:35:27 PM
TimeValue()
Purpose:
Returns a time value
DataType:
Time
Syntax:
TimeValue(time)
Arguments:
"time" is a string expression representing a valid time.
Sample:
response.write TimeValue("8:12:56 PM")
Result:
8:12:56 PM
TypeName()
Purpose:
Returns a type value
DataType:
String
Syntax:
TypeName(varname)
Arguments:
"varname" can be anything.
Sample:
i = 123.45
response.write TypeName(i) & "
"
k = "Hi"
response.write TypeName(k) & "
"
Set con = Server.CreateObject("ADODB.Connection")
response.write TypeName(con)
Result:
Double
String
Connection
UBound()
Purpose:
Returns the largest available subscipt for a dimension of an array.
DataType:
Integer
Syntax:
Ubound(arrayname [, dimension])
Arguments:
"arrayname" is an array;
"dimension" (optional) is a number indicating the dimension to find the upper bound
Sample:
i = Array("Monday","Tuesday","Wednesday")
response.write UBound(i)
Result:
2
UCase()
Purpose:
Returns a string that has been converted to uppercase characters.
DataType:
String
Syntax:
Ucase(String)
Arguments:
"string" is any valid string expression
Sample:
response.write UCASE("This is a test")
Result:
THIS IS A TEST
arType()
Purpose:
Returns the subtype of a variable
DataType:
Integer
Syntax:
VarType(varName)
Arguments:
"varName" can be anything
Sample:
i = 243.432
response.write varType(i)
Result:
5
Comments:
Use TypeName() function to obtain the type name directly. Or refer to varType constant.
WeekDay()
Purpose:
Returns a whole number representing the day of the week
DataType:
Integer
Syntax:
WeekDay(date [, firstdayofweek])
Arguments:
"date" is any valid date expression;
"firstdayofweek" is an optional date constant to assign the first day of week.
Sample:
response.write WeekDay(Date)
Result:
5
WeekDayName()
Purpose:
Returns the specified day of the week
DataType:
String
Syntax:
WeekDayName(weekday [, Abb [, firstdayofweek]])
Arguments:
"weekday" is the numeric representation for the day of the week;
"Abb" is an optional boolean value (if set to true, the weekday name will be abbreviated; if set to
false, the full weekday name is displayed);
"firstdayofweek" is an optional date constan
Sample:
response.write WeekDayName(WeekDay(Date))
Result:
Thursday
Year()
Purpose:
Returns the current year
DataType:
Integer
Syntax:
Year(date)
Arguments:
"date is any valid date expression
Sample:
response.write Year(now)
Result:
2010