我想通过让用户里Calendar选择一个日子,然后返回它是全年的第几个星期。应该怎么操作呢?

解决方案 »

  1.   

    下面的代码示例显示根据 FirstDayOfWeek 和所用的 CalendarWeekRule,GetWeekOfYear 的结果有何不同。如果指定日期为某一年的最后一天,则 GetWeekOfYear 返回这一年的星期总数。[Visual Basic] 
    Imports System
    Imports System.GlobalizationPublic Class SamplesCalendar   Public Shared Sub Main()
          
          ' Gets the Calendar instance associated with a CultureInfo.
          Dim myCI As New CultureInfo("en-US")
          Dim myCal As Calendar = myCI.Calendar
          
          ' Gets the DTFI properties required by GetWeekOfYear.
          Dim myCWR As CalendarWeekRule = myCI.DateTimeFormat.CalendarWeekRule
          Dim myFirstDOW As DayOfWeek = myCI.DateTimeFormat.FirstDayOfWeek
          
          ' Displays the number of the current week relative to the beginning of the year.
          Console.WriteLine("The CalendarWeekRule used for the en-US culture is {0}.", myCWR)
          Console.WriteLine("The FirstDayOfWeek used for the en-US culture is {0}.", myFirstDOW)
          Console.WriteLine("Therefore, the current week is Week {0} of the current year.", myCal.GetWeekOfYear(DateTime.Now, myCWR, myFirstDOW))
          
          ' Displays the total number of weeks in the current year.
          Dim LastDay = New System.DateTime(DateTime.Now.Year, 12, 31)
          Console.WriteLine("There are {0} weeks in the current year ({1}).", myCal.GetWeekOfYear(LastDay, myCWR, myFirstDOW), LastDay.Year)
       End Sub 'Main 
    End Class 'SamplesCalendar
      

  2.   

    DateTime类型有这个方法GetWeekOfYear()
      

  3.   

    <%
    dim weeknum,data
    weeknum = weekDay(now(),1)
    select case weeknum
    case "1"
      data="星期天"
    case "2"
      data="星期一"
    case "3"
      data="星期二"
    case "4"
      data="星期三"
    case "5"
      data="星期四"
    case "6"
      data="星期五"
    case "7"
      data="星期六"
    case else
      data="错误的时间"
    end select
    response.write data
    %>
      

  4.   

    ((DateTime)你选择的日期).GetWeekOfYear()就可以了
      

  5.   

    我怎么找不到datetime有这么个方法啊?