I have a method in a DAL class:
public IList<HouseHold> FindByDate(DateTime start, DateTime end)
{
using (ISession session = NHibernateHelper.AbreSession())
{
return session.CreateCriteria<HouseHold>()
.Add(Expression.Between("RegistrationDate", start, end))
.List<HouseHold>();
}
}
With this, I expected to get data from dates between a closed interval. But when I use this method and it the result is a left-closed interval, like this:
private IList<HouseHold> LoadData()
{
hh = dao.FindByDate(start.SelectedDate.Value, end.SelectedDate.Value);
return hh;
}
I choose dates between 20/08/2015 and 22/08/2015 from DataPicker
(WPF), it shows results from 20 to 21. But When I choose dates 20/08/2015 and 23/08/2015 it shows results from 20 to 22, while I know that are results from 23!
What's wrong?
Seems we have to convert morning time to midnight time. I.e from
23/08/2015 00:00
- we need 23/08/2015 23:59
The most simple way would be just to add a day
.Add(Expression.Between("RegistrationDate", start, end.AddDay(1)))