比较两个日期时间我有问题。我在我的数据库中有很多重复记录,我需要获取实际数据。我用它来获取实际数据Linq Max()。
在数据库表格中,我有时间采用以下格式:
2017-01-03 09:19:21.220
当我尝试使用LINQ过滤实际数据时
.Where(y=> y.EditDate == DB.Table.Max(q => q.EditDate.Value))
如果我尝试让MaxDate分开var
var maxDate = DB.Table.Max(q => q.EditDate);
我有这种格式的日期
03/01/2017 09:19:21
我怎样才能解决这个问题,因为如果我没有弄错的话,Linq Max()不会返回mili和微秒。
感谢。
答案 0 :(得分:0)
var <div class="width20 overflowYAuto text-center" style="padding: 5px; height: 200px;">
<div style="height:100%;">
<div class="cal_day" style="border: solid 1px black; height:90%; background-color: rgba(255,0,0,0.2)">
<p class="redText"><small>@Model.HolidayFriday</small></p>
@foreach (var booking in Model.WeekEvents.ScheduleFriday.Where(e => e.SchoolClassId == @item.DetailId).OrderBy(e => e.Events.Min(ev => ev.StartDate)).ToList())
{
if (@booking.Lecture)
{
<div class="innerbox blueBox hidden-sm hidden-xs cal_event_allteachers cal_event" onclick="showLectureSessionDetails('@booking.Id')" title="Visa mer information">
@Html.HiddenFor(b => booking.StartTimeText, new { @class = "cal_event_start_allteachers cal_event_start" })
@Html.HiddenFor(b => booking.EndTimeText, new { @class = "cal_event_end_allteachers cal_event_end" })
<div class="floatLeft">
<p class="paragraphSchadule">
<b>@booking.DisplayRow1</b><br />
<b>@booking.DisplayRow2</b><br />
<b>@booking.DisplayRow3</b><br />
<b>@booking.DisplayRow4</b><br />
<b>@booking.DisplayRow5</b><br />
</p>
</div>
</div>
<div class="innerbox blueBox text-center visible-sm visible-xs" onclick="showLectureSessionDetails('@booking.Id')" title="Visa mer information">
<p class="paragraphSchadule">
<b>Info</b>
</p>
</div>
}
else if (@booking.FieldTrip)
{
<div class="innerbox yellowBox hidden-sm hidden-xs cal_event_allteachers cal_event" onclick="showFieldTripSessionDetails('@booking.Id')" title="Visa mer information">
@Html.HiddenFor(b => booking.StartTimeText, new { @class = "cal_event_start_allteachers cal_event_start" })
@Html.HiddenFor(b => booking.EndTimeText, new { @class = "cal_event_end_allteachers cal_event_end" })
<div class="floatLeft">
<p class="paragraphSchadule">
<b>@booking.DisplayRow1</b><br />
<b>@booking.DisplayRow2</b><br />
<b>@booking.DisplayRow3</b><br />
<b>@booking.DisplayRow4</b><br />
</p>
</div>
</div>
<div class="innerbox yellowBox text-center visible-sm visible-xs" onclick="showFieldTripSessionDetails('@booking.Id')" title="Visa mer information">
<p class="paragraphSchadule">
<b>Info</b>
</p>
</div>
}
else
{
<div class="innerbox greenBox hidden-sm hidden-xs cal_event_allteachers cal_event" onclick="showBookingSessionDetails('@booking.Id')" title="Visa mer information">
@Html.HiddenFor(b => booking.StartTimeText, new { @class = "cal_event_start_allteachers cal_event_start" })
@Html.HiddenFor(b => booking.EndTimeText, new { @class = "cal_event_end_allteachers cal_event_end" })
<div class="floatLeft">
<p class="paragraphSchadule">
<b>@booking.DisplayRow1</b><br />
<b>@booking.DisplayRow2</b><br />
<b>@booking.DisplayRow3</b><br />
</p>
</div>
</div>
<div class="innerbox greenBox text-center visible-sm visible-xs" onclick="showBookingSessionDetails('@booking.Id')" title="Visa mer information">
<p class="paragraphSchadule">
<b>Info</b>
</p>
</div>
}
}
</div>
</div>
</div>
实际上存储了毫秒,但调试器中的显示使用的格式为maxDate
而没有dd/MM/yyyy HH:mm:ss
在手表中试试.fff
。