2014-02-19 47 views
0

所以我唯一的价值就是这个月。例如,今年2月,我如何知道第一周的日子是1,第二周是2 - 8,依此类推。有没有办法获得本月的一周的日期?

我正在使用它来生成报告,并且还应该有一个每周报告。也许你可以给我另一种拉本报告的方式。

我为这个系统使用了经典的asp和javascript。

+0

你想要一个[标签:Java脚本]或[标签:ASP-经典]解决方案? – Lankymart

回答

0

这是一个很好用的解决方案已经有一段时间了。

<% 
' Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved. 
' 
' This work is licensed under the Creative Commons Attribution License. To view 
' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or 
' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 
' 94305, USA. 

' Check if a year is a leap year. 
function isLeapYear(someYear) 
    if someYear Mod 4 = 0 and (someYear Mod 100 <> 0 or (someYear Mod 100 = 0 and someYear Mod 400 = 0)) then 
     isLeapYear = True 
    else 
     isLeapYear = False 
    end if 
end function 

' Returns the number of days in a given month (and in the case of February, for the given year). 
' REQUIRES: isLeapYear() 
function MonthDays(someMonth, someYear) 
    select case someMonth 
    case 1, 3, 5, 7, 8, 10, 12 
     MonthDays = 31 
    case 4, 6, 9, 11 
     MonthDays = 30 
    case 2 
     if isLeapYear(someYear) then 
      MonthDays = 29 
     else 
      MonthDays = 28 
     end if 
    end select 
end function 
%> 

要使用它

<% 
Dim daysinmonth 
'Number if days in January 2014 
daysinmonth = MonthDays(1, 2014) 
%> 
相关问题