[C#] DateTime 이번달 시작일, 이번달 마지막일, 마지막 2주

Jeini·2025년 4월 10일
0

🍇 C#

목록 보기
12/12
// 이번 달의 시작일
        DateTime firstDayOfMonth = new DateTime(currentDate.Year, currentDate.Month, 1);

        // 이번 달의 마지막 일
        DateTime lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1);

        // 마지막 2주
        DateTime lastTwoWeeksStart = lastDayOfMonth.AddDays(-13); // 마지막 2주의 시작일
        DateTime lastTwoWeeksEnd = lastDayOfMonth; // 마지막 2주의 종료일
        
        if(currentDate >= lastTwoWeeksStart || currentDate <= lastTwoWeeksEnd) 
        {    
            PrintLog("마지막 2주 안에 듬");
            //T_WOS_DT.Rows [i] ["선발주"] = "X";
            
        }
profile
Fill in my own colorful colors🎨

0개의 댓글