TroubleShooting

parameters describe an un representable datetime

S_sun 2025. 11. 27. 14:31

🔥 문제발생

  • parameters describe an un representable datetime
    • 초기 일자 설정 오류 (오늘날짜 ~ 한달 뒤)
      • 2025-10-31이면 2025-11-31이 없기에 에러.

 

해결방법

  • 무조건 월말로 설정.
    • 2025-11-31이면 2025-12-01로 설정.
DateTime today = DateTime.Today;
int nextMonth = today.Month == 12 ? 1 : today.Month + 1;
int nextYear = today.Year == 12 ? today.Year + 1 : today.Year;

DateTime startDate = sDate ?? today;
DateTime endDate = eDate ?? new DateTime(nextYear, nextMonth, DateTime.DaysInMonth(nextYear, nextMonth));
728x90
반응형

'TroubleShooting' 카테고리의 다른 글

VS SSL 인증서 오류  (0) 2025.11.27
암복호화  (0) 2025.11.25
DB 값 SetValue를 이용해 값 Insert  (0) 2025.11.25
DB Multi-Insert  (0) 2025.11.25