asp获取当前时间是第几周和指定周数的日期范围函数

[ 2011-12-05 08:33:34 | 作者: admin ]
字号: | |
获取当前时间是第几周函数:
Function GetWeekNo(InputDate)

dim pytY,pytNewYear,pytNewYearWeek,pytAllDay,pytBanWeek,NumWeek

NumWeek = 0

pytY = Year(InputDate)

pytNewYear=pytY &"-1-1"

pytNewYearWeek = Weekday(pytNewYear)

pytAllDay = DateDiff("d",pytNewYear,InputDate)

pytBanWeek = 8-pytNewYearWeek

if pytBanWeek<7 Then

NumWeek = 1

pytAllDay = pytAllDay - pytBanWeek

end if

tempx = pytAllDay/7


tempx = -Int(-tempx)

NumWeek = NumWeek+tempx

GetWeekNo = NumWeek

end Function



指定周数的日期范围函数
'函数名 getDateRange
'函数 index -数值型:指定周数
Function getDateRange(byVal Index)
Dim CurDate, retDate, Days, retVal
CurDate = CDate(Year(Date()) & "-1-1")
if (WeekDay(CurDate)<>1) Then Index =Index-1
Days=Index * 7
retDate=DateAdd("d", (Days - 1), CurDate)
if (retDate < CurDate) Then retDate=CurDate
retDate=DateAdd("d", -Weekday(retDate), retDate)
if (retDate< CurDate) then
retVal=CurDate & "->" & DateAdd("d", 7, retDate)
else
retVal=retDate + 1 & "->" & DateAdd("d", 7, retDate)
end if
getDateRange = retVal
End Function

评论Feed 评论Feed: http://blog.xg98.com/feed.asp?q=comment&id=1758

这篇日志没有评论。

此日志不可发表评论。