Domanda

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));
È stato utile?

Soluzione

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));
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top