'C#'에 해당되는 글 20건

  1. 2009.02.09 WeekOfMonth 구하기!!! 1
C#2009. 2. 9. 13:09


흐흐흐

직접짯다... 흐뭇하네~~~ ㅋㅋㅋ

정말정말 힘들게~~~ ㅎㅎㅎㅎㅎ 

 

 

DateTime dTime = DateTime.Now;            
string FirstOfMonth = DateTime.Now.ToString("yyyy-MM-01");
DateTime dt = new DateTime();DateTime.TryParse(FirstOfMonth, out dt);
CultureInfo myCI = new CultureInfo("en-US");
Calendar myCal = myCI.Calendar;
CalendarWeekRule myCWR = myCI.DateTimeFormat.CalendarWeekRule;
DayOfWeek myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek;

// 오늘 몇주차
int WeekOfToday = myCal.GetWeekOfYear(dTime, myCWR, myFirstDOW); 

// 오늘이 있는달 첫날짜 주차
int WeekOfFirstday= myCal.GetWeekOfYear(dt, myCWR, myFirstDOW); 
int WeekOfMonth = WeekOfToday - WeekOfFirstday;
textBox2.Text = (WeekOfMonth + 1).ToString();

Posted by 댓거리사랑