سؤال

I have stored the date in my database (not months).i want to get the records from particular month.Is it possible to write criteria for this in hibernate3?

هل كانت مفيدة؟

المحلول

You can write like this

Date startDate = 2014-03-01

Date endDate = 2014-03-31

Criteria criteria = getSession().createCriteria(getDomainClass()); criteria.add(Restrictions.between("date", startDate, endDate));

(OR)

If your date format is "YYYY-MM-DD"

String date = "2014-03";

Criteria criteria = getSession().createCriteria(getDomainClass());

criteria.add(Restrictions.like("date", date));

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top