Hi, i have three attributes of datetime: Time_start, Time_fail, Time_pass.
i want to get information between two date.
so in view, i will ask for datestart and dateEnd to get the date interval, and compare with the Time_Start
then, between three date, i want to choose the latest date to display. how to i code that?
What I have tried:
in view, i ask for date in textbox like this:
<div class="form-group">
@Html.TextBox("DateStart", "", new { @class = "date-picker form-control", @placeholder = "Date Start", @autocomplete = "off" })
</div>
<div class="form-group">
@Html.TextBox("DateEnd", "", new { @class = "date-picker form-control", @placeholder = "Date End", style = "visibility: visible !important" })
</div>
<button type="submit" value="Search" class="btn btn-primary">Search</button>
in controller:
public ActionResult TesterPerformance(DateTime DateStart, DateTime DateEnd)
{
var selectdate = (from c in db.Information
where c.Time_start >= DateStart && c.Time_start <= DateEnd
select new DetailBundle
{
Time_start = c.Time_start,
Time_fail = c.Time_fail,
Time_pass = c.Time_pass
}).ToList();
ViewBag.datepick = selectdate;
return View();
now, i'm missing the part to compare the latest date to view and i did not have any idea to code that.
using this code also i got error as it says "
The parameters dictionary contains a null entry for parameter 'DateStart' of non-nullable type 'System.DateTime' for method 'System.Web.Mvc.ActionResult TesterPerformance(System.DateTime, System.DateTime)' in 'StorageHost.Controllers.HomeController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
"
please guide me through this as i'm still new with c# projects. thank you