antony--异域空间
性格左右命运,气度影响格局!
<%
Temp_F=firstday(2006)
response.Write Temp_F&"<br>"
response.Write DateDiff("ww","2006-1-1","2006-12-31")&"<br>" '计算一年有多少天
Temp_N=getfst(2006,52)
response.Write Temp_N&"<br>"
%>

<%

'计算某年第一周开始日期
function firstday(inputyear)
 for i=cdate(inputyear&"-1-1") to cdate(inputyear&"-1-7")
  if weekday(i)=2 then
   firstday=i
   exit for
  end if
 next
end function

'计算输入日期是该年第几周的函数
Function CalcWeekNo(InputDate)
 toyear=year(inputdate)
 fday=firstday(toyear)
 if datediff("d",fday,inputdate)<0 then
  fday=firstday(toyear-1)
 end if
 'calcweekno=fday
 daynum=datediff("d",fday,inputdate)
 calcweekno=int(daynum/7) 1
end function

'根据周数和年份,计算该周第一天
function getfst(inputyear,weekno)
 fday=firstday(inputyear)
 getfst=dateadd("d",(weekno-1)*7,fday)
end function
%>

posted on 2008-02-17 22:31  antony.net  阅读(1305)  评论(0编辑  收藏  举报