ASP functions are not case sensitive.
ASP functions are located between <% %>.
Below are some common ASP functions with coding examples.
ASP Function | Description of ASP Function |
Example of ASP Function |
Loops | ||
Do Until Loop | count = 1 Do Until count = 3 count = count +1 Loop |
|
Do While Loop | count = 1 Do While count <> 3 count = count +1 Loop |
|
Response Functions | ||
Response.Redirect | Redirect to another web page | Response.Redirect "default.asp" |
Response.Write | Display text on web page | Response.Write "Hi!" |
Date and Time Functions | ||
Date | Current date | Date() |
Now | Current date and time | Now() |
Day | Day of month from 1 to 31 | Day(Date()) OR Day(Now()) |
Month | Month of year from 1 to 12 | Month(Date()) OR Month(Now()) |
Year | Year | Year(Date()) OR Year(Now()) |
MonthName | Name of the Month | MonthName(Month(Date())) OR MonthName(Month(Now())) |
Weekday | Day of the week from 1 (Sunday) to 7 | Weekday(Date()) |
Time | Current time | Time() |
Minute | Minute from 0 to 59 | Minute(Now) OR Minute(Time) |
Second | Second from 0 to 59 | Second(Now) OR Second(Time) |
String Functions | ||
Chr | Returns character value of number between 0 and 255 | See asp-characters.asp |
FormatCurrency | Display a number in currency format | FormatCurrency("1003.99") |
FormatNumber | Display a number in double format with the designated positions after the decimal | FormatNumber(1003.9987987,2) |
inStr | Finds text in a string starting from left | inStr(Description,"Tom") If inStr(emailAddress, "@") = 0 Then |
inStrRev | Finds text in a string starting from right | inStrRev(Description,"Betty") If inStr(emailAddress, "@") = 0 Then |
isDate | Checks if string is a valid date | isDate(#02/30/20#) |
isNumeric | Checks if string is a valid number | isNumeric("123gfd") |
lCase | Lower case | lCase("TOM") |
uCase | Upper case | uCase("tom") |
Len | Length of string | If Len(firstName) <> 0 Then |
Replace | Replace one string with another | Replace(description,"Tom","Ted") |
Left | Left("How are you",5) | |
Mid | Mid("How are you",4,2) | |
Right | Right("How are you",3) | |
Trim | Remove spaces from start and finish of string | Trim(" How are you? ") |