문제

I am trying to retrieve records based on a specific date field. My criteria is to only show records whose values do not fall within current month or greater than today's date.

I already coded a criteria that is working for getting records with future dates. Could someone please assist me on how to solve the problem with showing records that are not in current month.

Thank you very much!

var criteria = Session.CreateCriteria<GLEntry>();
criteria.Add(Expression.Gt("EffectiveDate", DateTime.Today));
도움이 되었습니까?

해결책

Just need to to a less than with the first day of the current month.

var firstOfMonth = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
criteria.Add(Expression.Lt("EffectiveDate", firstOfMonth));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top