Member
33 Points
May 09, 2019 05:43 AM|aabedeni056|LINK
hello . i change my column table to (from nvarchar date to datetime date , int time to datatime time ) but when save .it give error :
please help me . thank you ...
Contributor
3080 Points
May 09, 2019 08:02 AM|Yuki Tao|LINK
Hi aabedeni056,
aabedeni056The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.
DATETIME supports 1753/1/1 to "eternity" (9999/12/31), while DATETIME2 supports 0001/1/1 through eternity.
So,the date range supported is quite different,this is the cause of the error message.
You could refer to this article about some solutions,like the below:
1. Change the storage to DateTime2 in the database.
[Column(TypeName="datetime2")] public DateTime date{ get; set; }
2. Change the property to be Nullable
public DateTime? date{ get; set; }
3.Specify a default value within an acceptable range
public class Myobject { public Myobject() { date= DateTime.Now; } public DateTime date{ get; set; } }
Best Regards.
Yuki Tao
1 reply
Last post May 09, 2019 08:02 AM by Yuki Tao