程序园

弹奏键盘人生,拂去青春的尘土,留下的只有岁月的痕迹
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

private int GetWeek(DateTime now)
{
      System.Globalization.GregorianCalendar gc = new System.Globalization.GregorianCalendar();
      int weekOfYear = gc.GetWeekOfYear(now, System.Globalization.CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
      return weekOfYear;
}

C#:GetWeek(GetWeek(DateTime.Now))

对应

SQL:SELECT DATEPART(WEEK,GETDATE())