ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.[Solved] ASP.Net Error: Cannot implicitly convert type System.DateTime? to int<p>Hi <a class="username" rel="mahesh213"> mahesh213</a>,</p> <p>This error is because DateTime? means it's nullable DateTime.</p> <p>So before assigning it to DateTime you need to check if it contains value and only then assign.</p> <p>Check if datetime contains value and if not return any other value which you want.</p> <p>Use the below code.</p> <pre class="brush: csharp">[HttpPost] public JsonResult getAll1(DateTime? Id5) { DateTime dt = Id5.HasValue ? Id5.Value : DateTime.Now; var result = db.PayProcess(dt).ToList(); var JsonResult = Json(result, JsonRequestBehavior.AllowGet); JsonResult.MaxJsonLength = int.MaxValue; return JsonResult; }</pre> <p>Or change signature of method to remove nullable.</p> <pre class="brush: csharp">[HttpPost] public JsonResult getAll1(DateTime Id5) { &nbsp;&nbsp;&nbsp; var result = db.PayProcess(Id5).ToList(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var JsonResult = Json(result, JsonRequestBehavior.AllowGet); &nbsp;&nbsp;&nbsp; JsonResult.MaxJsonLength = int.MaxValue; &nbsp;&nbsp;&nbsp; return JsonResult; }</pre>https://www.aspforums.net:443/Threads/501405/Solved-ASPNet-Error-Cannot-implicitly-convert-type-SystemDateTime-to-int/https://www.aspforums.net:443/Threads/501405/Solved-ASPNet-Error-Cannot-implicitly-convert-type-SystemDateTime-to-int/Tue, 27 Aug 2019 01:37:23 GMT