ASP之函数的定义
- 格式:doc
- 大小:23.50 KB
- 文档页数:1
ASP常用内置函数在ASP中,把带有返回值的这样的一段代码叫做函数。
例如通过编写一段代码计算出一个自然数是否是质数,返回给调用程序,由于调用程序需要知道那个自然数是否是质数,所以必须要返回一个值。
1,日期/时间函数这些函数包括对“年”、“月”、“日”、“时”、“分”、“秒”、“星期”等的显示。
(1)Now函数:根据计算机系统设定的日期和时间,返回当前的日期和时间值。
使用方法now();(2)Date函数:只返回当前计算机系统设定的日期值。
使用方法:date();(3)Time函数:只返回当前计算机系统设定的时间值。
使用方法:time();(4)Year函数:返回一个代表某年的整数。
使用方法:year(date),其中date参数是任意的可以代表日期的参数,比如“year(date())”就表示是从“date()”得出的日期中提取其中“年”的整数。
另外,还可以这样应用:“year(#520,2006#)”表示提取“2006年5月20日”中“年”的整数值。
关于“520,2006”,也可使用“5-20-2006”、“5/20/2006”等形式表现,即“某月某日”和“某年”的组合。
同时注意使用“#”进行包括以表示日期值。
(5)Month函数:返回1到12之间的整数值,表示一年中某月。
使用方法:month(date)。
关于参数date的说明和year函数相同。
但要注意日期的正确性,比如“#13-31-2006#”,根本就没有“13”月,肯定是错误的了。
(6)Day函数:返回1到31之间的整数值,表示一个月中的某天。
使用方法:day(date)。
关于参数date的说明和year函数相同。
同样要注意日期的正确性,比如“#2-30-2006#”其中对“2”月定义的“30”日这天就是错误的。
(7)Hour函数:返回0到23之间的整数值,表示一天中的某个小时。
使用方法:hour(time)。
其中参数time是任意的可代表时间的表达式。
ASP 常用的内置函数
介绍一个VBScript中为用户提供的各种类型内置函数。
使用他们可以使编写程序更加简单、快速、高效。
这些内置函数由VBScript预定义,其功能已经由VBSc ript系统实现,因此在编写程序时只需要直接调用即可。
1.字符串函数
在VBScript中字符串函数用于对字符串数据进行操作。
下面列出了一些常用的字符串函数及其功能,如表3-4所示。
2.数值函数
数值函数在程序中用于进行数值运算,如求某数的平方根,对数等。
表3-5列出了一些常用的数值函数。
表3-5 数值函数
3.转换函数
转换函数用于在Variant的各子类型之间进行数据类型的转换,这样方便进行各种运算。
下面将对常用的各种转换函数进行介绍,如表3-6所示。
表3-6 转换函数
4.布尔函数
VBScript中的布尔函数主要用于对数据类型的判断,以方便对该数据进行相应的处理。
例如,判断某数是否为数字类型。
在表3-7中列出了VBScript中常用的几个布尔函数。
表3-7 布尔函数
5.时间和日期函数
VBScript中的日期和时间函数用于获取系统的当前日期和时间,以及对日期时间类型数据进行处理。
表3-8列出了几种常用的时间和日期函数。
表3-8 时间和日期函数。
ASP的自定义实用函数表(1)2004-9-20 6:55:00 作者:模板天下收集整理来源:未知网友评论 0 条论坛'汉字判断function isChinese(para)on error resume nextif isNUll(para) thenisChinese=falseexit functionend ifif trim(para)="" thenisChinese=falseexit functionend ifdim cfor i=1 to len(para)c=asc(mid(para,i,1))if c>=0 thenisChinese=falseexit functionend ifnextisChinese=trueif err.number<>0 then err.clearend function%>如:if not isChinese(request("name")) thenerrmsg=errmsg+""+"<li>用户名应为汉字"founderr=trueelseusername=trim(request("name"))end if----------------------------------------------'替换指定文件内字符串的函数<%function FSOlineedit(filename,Target,String)Dim objFSO,objCountFile,FiletempDataSet objFSO = Server.CreateObject("Scripting.FileSystemObject")Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True) FiletempData = objCountFile.ReadAllobjCountFile.CloseFiletempData=Replace(FiletempData,Target,String)Set objCountFile=objFSO.CreateTextFile(Server.MapPath(filename),True) objCountFile.Write FiletempDataobjCountFile.CloseSet objCountFile=NothingSet objFSO = NothingEnd Functionresponse.write FSOlineedit("test.txt","世界","明天是一个好天去")%>----------------------------------------------'获取中文字符串拼音首字母串的函数<%response.write "<link href=style.css rel=stylesheet>"if request.form("content")="" thenresponse.write "<center><form method=post action=asd.asp><input name=content type=text>__<input type=submit></form>"elsefunction getpychar(char)tmp=65536+asc(char)if(tmp>=45217 and tmp<=45252) thengetpychar= "A"elseif(tmp>=45253 and tmp<=45760) thengetpychar= "B"elseif(tmp>=45761 and tmp<=46317) thengetpychar= "C"elseif(tmp>=46318 and tmp<=46825) thengetpychar= "D"elseif(tmp>=46826 and tmp<=47009) thengetpychar= "E"elseif(tmp>=47010 and tmp<=47296) thengetpychar= "F"elseif(tmp>=47297 and tmp<=47613) thengetpychar= "G"elseif(tmp>=47614 and tmp<=48118) thengetpychar= "H"elseif(tmp>=48119 and tmp<=49061) thengetpychar= "J"elseif(tmp>=49062 and tmp<=49323) thengetpychar= "K"elseif(tmp>=49324 and tmp<=49895) thengetpychar= "L"elseif(tmp>=49896 and tmp<=50370) thengetpychar= "M"elseif(tmp>=50371 and tmp<=50613) thengetpychar= "N"elseif(tmp>=50614 and tmp<=50621) thengetpychar= "O"elseif(tmp>=50622 and tmp<=50905) thengetpychar= "P"elseif(tmp>=50906 and tmp<=51386) thengetpychar= "Q"elseif(tmp>=51387 and tmp<=51445) thengetpychar= "R"elseif(tmp>=51446 and tmp<=52217) thengetpychar= "S"elseif(tmp>=52218 and tmp<=52697) thengetpychar= "T"elseif(tmp>=52698 and tmp<=52979) thengetpychar= "W"elseif(tmp>=52980 and tmp<=53640) thengetpychar= "X"elseif(tmp>=53689 and tmp<=54480) thengetpychar= "Y"elseif(tmp>=54481 and tmp<=62289) thengetpychar= "Z"else '如果不是中文,则不处理getpychar=charend ifend functionfunction getpy(str)for i=1 to len(str)getpy=getpy&getpychar(mid(str,i,1))nextend functioncontent=request.form("content")response.write "<center>"&getpy(content)&chr(10)response.write "<br><br><br><a href=# onclick=javascript:history.go(-1)>返回</a>" end if%>--------------------------------------------ip限制函数'******************************'Function CheckIp(cInput_Ip,cBound_Ip)'Created by qqdao, qqdao@ 2001/11/28'说明:首先需要根据;号循环,然后判断是否含有"-",如果有则进行拆分处理,最后判断是否在范围内'参数: cInput_Ip,代检查的ip' cBound_Ip,给定的范围格式为,单个ip,和范围ip,范围ip最后使用”-“分割,如果是“*”则必须放到最后一位' 每个范围后添加":ALLOW"表示允许登陆,添加":REFUSE"表示拒绝登陆。
函数列表:'1:建立数据库的连接ConnOpen(DataBaseConnectStr,DBType,Conn_object)'2:断开数据库的连接ConnClose(Conn_object)'3:防止SQL注入SafeRequest(paraName,paraType)'4:格式化日期DateFormat(dateStr,dateType)'5:显示错误提示ShowErr(errStr)'6:查询字符串中特定数据SelectStr(contentStr,patternStr,patternNum)'7:过滤指定字符Leach(contentStr,badWords)'8:远程文件内容抓取Seize(urlStr)'9:数据流编码处理BytesToBstr(body,cset)'10:编码cookies codeCookie(contentStr)'11:解码cookies DecodeCookie(contentStr)'12:检验数据提交来源是否合法ChkPost()'13:个性化加密MyEncrypt(StrPassword)'14:禁止浏览器缓存本页NoBuffer()'15:网页格式化输入文本HTMLEncode(fString)'16:从头部截取字符串的指定长度(按字符数算) GotTopic(Str,StrLen)'17:检测验证码CheckRadomPass(RadomPass)'18:生成验证码GetCode()'19:获取客户端操作系统版本GetSystem()'20:数据库事务处理ConnManage(Conn_object)'21:快速排序(递归)QuickSort(arr,Low,High)'22:将数组的元素以特定字符串连起来arr_join(arr,character)'23:返回字符串以某分割符分割的数目count_character(str,character)'24:截取含有分割符的字符串中指定数目的字符串inter_str_by_character_num(str,character,start,num)'25:利用Stream下载文件downloadFile(strFile)'26:返回信息send_back(ResultWords)'27:获取错误信息get_err()'28:与SafeRequest相反SafeResponse(content)'29:保存远程图片SaveRemoteFile(LocalFileName,RemoteFileUrl)'30: ...dim language_arr(10)language_arr(0) = "数据库连接的参数设置错误!"language_arr(1) = "数据库连接的类型参数设置错误!"language_arr(2) = "数据库连接失败!"language_arr(3) = "非法的参数值!"language_arr(4) = "参数值不是有效的日期格式!"language_arr(5) = "操作失败!"language_arr(6) = "栏目有重名!"language_arr(7) = "栏目名称为空!"language_arr(8) = "栏目文件夹创建失败!"language_arr(9) = "您没有此权限!"'============================================================================================================================'函数ID:1'函数作用:建立数据库的连接'作者名称:茫仔xiamangmang@ 博客:'建立时间:2006-2-15 10:28'修改时间:'传人参数:' connectStr:数据库连接字符串' connectType:数据库类别-数字型,0为Access,1为MS SQL'返回值:'=================================================================== =========================================================sub ConnOpen(DataBaseConnectStr,DBType,Conn_object)Set Conn_object = Server.Createobject("adodb.connection")if DataBaseConnectStr = "" then call ShowErr(language_arr(0))if DBType = 0 thenConn_object.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DataBaseConnectStrelseif DBType = 1 thenConn_object.Open "Provider=SQLOLEDB.1;" & DataBaseConnectStrelsecall ShowErr(language_arr(1))end iferr.clearend sub'=================================================================== ========================================================='函数ID:2'函数作用:断开数据库的连接'作者名称:茫仔xiamangmang@ 博客:'建立时间:2006-2-16 15:10'修改时间:'传人参数:'返回值:'=================================================================== =========================================================Sub ConnClose(Conn_object)Conn_object.closeset Conn_object = nothingEnd sub'=================================================================== ========================================================='函数ID:3'函数作用:防止SQL注入'作者名称:/infoview/Article_2906.html'建立时间:2006-2-16 15:32'修改时间:'传人参数:' paraName:参数名称-字符型' paraType:参数类型-数字型(1表示以上参数是数字,0表示以上参数为字符)'返回值:' 过滤后的字符串'=================================================================== =========================================================Function SafeRequest(paraName,paraType)dim paraValueparaValue = Request(paraName)select case paraTypecase 0paraValue = replace(paraValue,"'","[system:34]")paraValue = replace(paraValue,"=","[system:61]")case 1if not IsNumeric(paraValue) then call ShowErr(language_arr(3))case -1if not IsNumeric(paraValue) then call ShowErr(language_arr(3))if paraValue = "" then paraValue = 0case elseif len(paraValue) > paraType then call ShowErr(language_arr(3))paraValue = replace(paraValue,"'","[system:34]")paraValue = replace(paraValue,"=","[system:61]")end selectSafeRequest = paraValueEnd function'=================================================================== ========================================================='函数ID:4'函数作用:格式化日期'作者名称:茫仔xiamangmang@ 博客:'建立时间:2006-2-16 15:45'修改时间:'传人参数:' dateStr:日期字符串' paraType:日期类型-数字型'返回值:' 格式化后的日期'=================================================================== =========================================================Function DateFormat(dateStr,dateType)Dim dateStringif IsDate(dateStr) = False thencall ShowErr(language_arr(4))end ifSelect Case dateTypeCase "1"dateString = Year(dateStr)&"-"&Month(dateStr)&"-"&Day(dateStr)Case "2"dateString = Year(dateStr)&"."&Month(dateStr)&"."&Day(dateStr)Case "3"dateString = Year(dateStr)&"/"&Month(dateStr)&"/"&Day(dateStr)Case "4"dateString = Month(dateStr)&"/"&Day(dateStr)&"/"&Year(dateStr)Case "5"dateString = Day(dateStr)&"/"&Month(dateStr)&"/"&Year(dateStr)Case "6"dateString = Month(dateStr)&"-"&Day(dateStr)&"-"&Year(dateStr)Case "7"dateString = Month(dateStr)&"."&Day(dateStr)&"."&Year(dateStr)Case "8"dateString = Month(dateStr)&"-"&Day(dateStr)Case "9"dateString = Month(dateStr)&"/"&Day(dateStr)Case "10"dateString = Month(dateStr)&"."&Day(dateStr)Case "11"dateString = Month(dateStr)&language_arr(6)&Day(dateStr)&language_arr(7)Case "12"dateString = Day(dateStr)&language_arr(7)&Hour(dateStr)&language_arr(8)case "13"dateString = Day(dateStr)&language_arr(7)&Hour(dateStr)&language_arr(8)Case "14"dateString = Hour(dateStr)&language_arr(8)&Minute(dateStr)&language_arr(9)Case "15"dateString = Hour(dateStr)&":"&Minute(dateStr)Case "16"dateString = Year(dateStr)&language_arr(5)&Month(dateStr)&language_arr(6)&Day(dateStr)&languag e_arr(7)Case ElsedateString = dateStrEnd SelectDateFormat = dateStringEnd Function'=================================================================== ========================================================='函数ID:5'函数作用:显示错误提示'作者名称:茫仔xiamangmang@ 博客:'建立时间:2006-2-16 16:29'修改时间:'传人参数:' errStr:错误提示-字符型'返回值:返回提交页面'=================================================================== =========================================================sub ShowErr(errStr)Response.Write("<script>alert("""&errStr&""");location.href=""javascript:history.back()"";</ script>")Response.EndEnd sub'=================================================================== ========================================================='函数ID:6'函数作用:查询字符串中特定数据'作者名称:茫仔xiamangmang@ 博客:'建立时间:2006-2-16 16:40'修改时间:'传人参数:' contentStr:查询字符串' patternStr:匹配式字符串' patternNum:查询定位-数字型'返回值:' 找不到返回false' patternNum为-1返回所有匹配字符串并以[10]隔开' 否则返回指定位置的字符串'=================================================================== =========================================================Function SelectStr(contentStr,patternStr,patternNum)dim objRegExp,matches,matcheif contentStr = "" thencall ShowErr(language_arr(12))end ifSet objRegExp=new RegExp '建立正则表达式objRegExp.pattern = patternStr '设置模式objRegExp.IgnoreCase =False '设置是否区分字符大小写objRegExp.Global=true '设置全局可用性objRegExp.pattern = patternStr '匹配式if objRegExp.test(contentStr) = false then '全局匹配SelectStr = falseelseSet matches = objRegExp.Execute(contentStr) '执行搜索if patternNum = -1 thenfor each matche in matchesSelectStr = SelectStr &"[10]"& matche.valuenextelseSelectStr = matches.Item(patternNum).valueend ifend ifSet objRegExp=NothingEnd Function'=================================================================== ========================================================='函数ID:7'函数作用:过滤指定字符'作者名称:茫仔xiamangmang@ 博客:'建立时间:2006-2-16 16:59'修改时间:'传人参数:' contentStr:源字符串' badWords:要过滤的字符串,若数目大于1则用英文状态的"^"隔开'返回值:' 返回过滤后的字符串'=================================================================== =========================================================Function Leach(contentStr,badWords)dim badWordsArr,ibadWordsArr = Split(badWords,"^")for i = 0 to UBound(badWordsArr)contentStr = replace(contentStr,badWordsArr(i),"")nextleach = contentStrend Function'=================================================================== ========================================================='函数ID:8'函数作用:远程文件内容抓取'作者名称:茫仔xiamangmang@ 博客:'建立时间:2006-2-16 17:24'修改时间:'传人参数:' urlStr:远程文件地址'返回值:' 返回远程文件内容'=================================================================== =========================================================function Seize(urlStr)dim connectif urlStr = "" thencall ShowErr(language_arr(13))elseSet connect = CreateObject("Microsoft.XMLHTTP") '建立XMLHTTP对象connect.open "GET",urlStr,false '设置参数,通信方式为get,请求为同步,后面还有两个可选属性:userID,password用于用户验证connect.send() '数据发送,Send方法的参数类型可以是字符串、DOM树或任意数据流Seize = BytesToBStr(connect.responseBody,"GB2312") '返回信息,编码为中文set connect = nothingend ifend function'=================================================================== ========================================================='函数ID:9'函数作用:数据流编码处理'作者名称:茫仔xiamangmang@ 博客:'建立时间:2006-2-16 17:30'修改时间:'传人参数:' body:数据内容' cset:编码格式'返回值:' 编码处理后的信息'=================================================================== =========================================================Function BytesT oBstr(body,cset)dim objstreamset objstream = Server.CreateObject("adodb.stream")objstream.Type = 1 '以二进制模式打开objstream.Mode =3objstream.Openobjstream.Write bodyobjstream.Position = 0objstream.Type = 2objstream.Charset = csetBytesToBstr = objstream.ReadT extobjstream.Closeset objstream = nothingEnd Function'=================================================================== ========================================================='函数ID:10'函数作用:编码cookies'作者名称:茫仔xiamangmang@ 博客:'建立时间:2006-2-16 17:36'修改时间:'传人参数:' contentStr:数据内容'返回值:' 编码处理后的信息,字符以"a"隔开'=================================================================== =========================================================Function codeCookie(contentStr)Dim i,returnStrFor i = Len(contentStr) to 1 Step -1returnStr = returnStr & Ascw(Mid(contentStr,i,1))If (i <> 1) Then returnStr = returnStr & "a"NextCodeCookie = returnStrEnd Function'=================================================================== ========================================================='函数ID:11'函数作用:解码cookies'作者名称:茫仔xiamangmang@ 博客:'建立时间:2006-2-17 16:58'修改时间:'传人参数:' contentStr:数据内容'返回值:' 解码处理后的信息'=================================================================== =========================================================Function DecodeCookie(contentStr)Dim iDim StrArr,StrRtnStrArr = Split(contentStr,"a")For i = 0 to UBound(StrArr)If isNumeric(StrArr(i)) = True ThenStrRtn = Chrw(StrArr(i)) & StrRtnElseStrRtn = contentStrExit FunctionEnd IfNextDecodeCookie = StrRtnEnd Function'=================================================================== ========================================================='函数ID:12'函数作用:检验数据提交来源是否合法'作者名称:茫仔xiamangmang@ 博客:'建立时间:2006-2-18 18:55'修改时间:'传人参数:''返回值:' Boolean'=================================================================== =========================================================Function ChkPost()Dim server_v1,server_v2Chkpost=Falseserver_v1=Cstr(Request.ServerVariables("HTTP_REFERER"))server_v2=Cstr(Request.ServerVariables("SERVER_NAME"))If Mid(server_v1,8,len(server_v2))=server_v2 Then Chkpost=TrueEnd Function'=================================================================== =========================================================。
1、asp函数大全之函数array()函数array()功能:创建一个数组变量格式:array(list)参数:list为数组变量中的每个数值列,中间用逗号间隔例子:<%asp=array("1","2","3")%>结果:asp被赋予为数组2、asp函数大全函数Creatobject()函数:Creatobject()功能:创建及返回一个ActiveX对象.格式:Creatobject(obname)参数bname是对象的名称例子:<%Set asp = Server.CreateObject("ADODB.Connection")%>3、asp函数大全之函数Date()函数Date()功能:返回当前系统(server端)的日期格式:Date()参数:无例子<%=date()%>4、asp函数大全函数Datediff()函数Datediff()功能:计算某量个指定的时间差格式: datediff(timeinterval,date1,date2[,firstdayofweek[,firs tdayofyear]])参数:timeinterval是时间单位;date1,date2是有效的日期表达式,firstdayofweek,firstdayofyear是任意选项.例子:<%fromDate=#8/8/2008#toDate=#8/8/2010#response.write"There are"&_DateDiff("d",fromDate,toDate)&_%>5、函数formatcurrency()函数formatcurrency()功能:转换成货币格式格式:formatcurrency(expression [,digit[,leadingdigit[,paren[,groupdigit]]]])参数:expression是有效的数字表达式;digit表示小数点后的位数;leadingdigit,paren,groupdigit是任意选项.例子<%=FormatCurrency(34.3456)%>结果34.356、asp函数大全之函数Isnumeric()函数Isnumeric()功能:返回一个布尔值,判断变量是否为数字变量,或者是可以转换成数字的其它变量.格式:isnumeric(expression)参数:expression是任意的变量.例子:<%i="234"response.write isnumeric(i)%>结果:true.7、asp函数大全之函数:Lbound()函数:Lbound()功能:返回一个数组的下界.格式:Lbound(arrayname[,dimension])参数:arrayname是数组变量,dimension是任意项例子:<%i=array("1","2","3")response.write lbound(i)%>结果:08、asp函数大全之函数left()功能:截取一个字符串的前部分;格式:left(string,length)参数:string字符串,length截取的长度.例子:<%=left("asp is a web!",3)%>结果:asp9、asp函数大全之函数ltrim()功能:去掉字符串前的空格.格式:ltrim(string)参数:string字符串.例子:<%=ltrim("this is a test!")结果:this is a test!10、asp函数大全之函数minute()功能:返回一数值,表示分钟格式:minute(time)参数:time是时间变量例子lt;%=minute(#12:23:34#)%>结果:2311、asp函数大全之函数monthname()功能:返回月份的字符串(名称).格式:Monthname(date[,abb])参数:date是日期变量,abb=true时则月份的缩写,例子:<%=monthname(#4/5/99#)%>结果:April12、asp函数大全之函数replace()功能:在字符串中查找,替代指定的字符串.格式:replace(strtobesearched,strsearchfor,strreplacewit h[,start[,count[,compare]]])参数:strtobesearched是字符串;strsearchfor是被查找的子字符串;strreplacewith是用来替代的子字符串.start,count,compare是任意选项.例子:<%strtest="this is an apple."response.write replace(strtest,"apple","orange") %>结果:this is an orange.13、asp函数大全之函数rnd()功能:返回一个随机数值格式:rnd[(number)]参数:number是任意数值.例子:<%randomize()response.write rnd()%>结果:0/1数值之一,无randomize(),则不能产生随机数.14、asp函数大全之函数rtrim()功能:去掉字符串后的空格.格式:rtrim(string)参数:string是字符串例子:<%response.write rtrim("this is a test!")%>结果:this is a test!15、asp函数大全之函数strReverse()功能:返回与原字符串排列逆向的字符串.格式:strreverse(string)参数:string是字符串例子<%=strreverse("this is a test!")结果:!tset a si siht16、asp函数大全之函数trim()功能:删去字符串前,后的空格.格式:trim(string)参数:string字符串.例子:<%strtest="this is a test!"response.write trim(strtest)%>结果:this is a test!17、asp函数大全之函数UCase()功能:将一字符类型变量的字符全部变换成大写字符.格式:Ucase(string)参数:string是字符串变量例子:<%str="THIS is Lcase!"response.write Lcase(str)%>结果:THIS IS LCASE!18、asp函数大全之函数Weekday()功能:返回一个整数,对应一周中的第几天.格式:Weekday(date[,firstofweek])参数:date为日期变量,firstofweek为任选项.例子:<%d=#5/9/00#response.write weekday(d)%>结果:3(3表示是星期二)19、asp函数大全之函数year()功能:返回日期表达式所在的年份.格式:year(date)参数:date是有效的日期表达式例子:<%=year(#8/9/99#)%>结果:199920、asp函数大全之函数Cint()函数Cint()功能:将一表达式/其它类型的变量转换成整数类型(int)格式:Cint(expression)参数:expression是任何有效的表达式/其它类型的变量例子:<%asp="234"response.write cINT(asp)+2%>结果:236函数Cint()将字符"234"转换成整数234.如果表达式为空,或者无效时,返回值为0;21、asp函数大全之函数Cstr()函数Cstr()功能:将一表达式/其它类型的变量转换成字符类型(string)格式:Cstr(expression)参数:expression是任何有效的表达式/其它类型的变量例子:<%asp=3+2response.write"Theresultis:"&cStr(asp)%>结果:函数Cstr()将整数5转换成字符"5".22、asp函数大全函数Dateadd()函数Dateadd()功能:计算某个指定的时间和格式:dateadd(timeinterval,number,date)参数:timeinterval是时间单位(月,日..);number是时间间隔值,date是时间始点.例子:<%currentDate=#8/8/2008#newDate=DateAdd("m",3,currentDate) response.write newDate%><%currentDate=#01:23:45PM#newDate=DateAdd("h",3,currentDate) response.write newDate其中"m"="month";"d"="day";如果是currentDate格式,则,"h"="hour";"s"="second";23、asp函数大全函数day()函数day()功能:返回一个整数值,对应于某月的某日格式:day(date)参数:date是一个有效的日期表达式;例子<%=date(#8/8/2010#)%>24、函数Formatdatetime()函数Formatdatetime()功能:格式化日期表达式/变量格式:formatdatetime(date[,nameformat])参数:date为有效的日期表达式/变量;nameformat是指定的日期格式常量名称.例子<%=formatdatetime("08/08/2008",vblongdate)%>--------------------------------------------------------------------------------描述返回表达式,此表达式已被格式化为日期或时间。