The Year, Month, and Day parameters describe an unrepresentable DateTime exception.

I add an object to the list in an ASP.NET MVC 3 application using the following code, but one of the properties of the object creates difficulties.

ls.Add(new UserRoleModel { UserRoleId = 1, UserName = "Paul", InsertDate = new DateTime(05, 24, 2012),InsertProgram="sqlplus",InsertUser="sp22",Role="Implementation Co-corindator"});

This builds, but when I go to the corresponding page, I get an exception with the following type:

Exception Details: System.ArgumentOutOfRangeException: Year, Month, and Day parameters describe an un-representable DateTime.

I tried to remove 0 per month, but get the same exception.

+5
source share
4 answers

The constructor DateTime that you call takes parameters in the order year, month, day.

, , , , . , , 2012 "".

+19

, , . ...

new Date(2013, 2, 30)

30 , .

new Date(2013, 2, 28)

.

+5

InsertDate / ,

DateTime InsertDate  = DateTime.Now;
+2

You use an invalid date-time, for example, during the month you can skip 13.14 days more than 31

or something similar that causes a problem.

+2
source

All Articles