函数作用: 输入:两个时间字符串,如2010-11和2011-4 输出:补齐两个时间字符串之间的年月,如:2010-11,2010-12,2011-1,2011-2,2011-3,2011-4 Function Show_Timein(STime_s,STime_e) dim DiffADate_m,k DiffADate_m = DateDiff("m", STime_s, STime_e) '日期之间并多少月 for k=0 to DiffADate_m if k=0 then Show_Timein ="'"&cstr(year(DateAdd("m", k, STime_s&"-01"))) & "-" & cstr(month(DateAdd("m", k, STime_s&"-01")))&"'" else Show_Timein = Show_Timein & "," & "'" & cstr(year(DateAdd("m", k, STime_s&"-01"))) & "-" & cstr(month(DateAdd("m", k, STime_s&"-01"))) &"'" end if next Show_Timein = Show_Timein End Function '调用 response.write Show_Timein("2010-12","2011-4") Response.Write("<br /><br />") Function Show_Timein1(oldTime,newTime) dim j,i j=DateDiff("m", oldTime,newTime) for i=0 to j Show_Timein1=Show_Timein1 & "'" &year(dateadd("m",i,oldTime))&"-"&month(dateadd("m",i,oldTime))& "'" & "," next If InStr(Right(Show_Timein1,1),",")>0 Then '判断取值 Show_Timein1=Left(Show_Timein1,Len(Show_Timein1)-1)'把最后一个字符去掉 End if End Function '调用 response.write Show_Timein1("2010-12","2011-4") |