Pregunta

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));
¿Fue útil?

Solución

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));
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top