i need help why this is doesn't work when i putting == instead of <= or >= with <= or >= working My view is
@using (Html.BeginForm("Index", "CTR", FormMethod.Get))
{
<div class="input-group col-md-5 col-md-push-3">
<span class="input-group-addon" id="basic-addon1">Date:</span>
@Html.TextBox("date", null, new { @class = "form-control datepicker", placeholder = "Choose Date" })
<span class="input-group-btn">
<button class=" btn btn-success" type="submit" value="search">Go</button>
</span>
</div>
}
And Controller
public ActionResult Index(DateTime? date)
{
Debug.WriteLine(date);
return View(db.Ctrs.Include(d => d.Citizens).Include(d => d.Exchange).Include(d => d.Tariffs).Where(d => d.Exchange.Date == date).ToList());
}
We need to know what's your database holding, what's your input and your output. Btw if you want to compare by day, you need to get only the date component of your dates. MSDN: System.DateTime.Date
At the end I think you need to do
d => d.Exchange.Date.Value.Date == date.Value.Date
In addition, you surely need to manage null values.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.