您的位置:首页 > 编程语言 > ASP

ASP计算周开始和一年有多少周及某年第一周开始日期

2008-02-17 22:31 363 查看
<%

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

%>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐