java - Hibernate criteria group by date without time -
this code give me list of 2 items datetime , count. need group date without time.
can give me clue how it? thanks!
criteria criteria = getsession().createcriteria(parcel.class); projectionlist projectionlist = projections.projectionlist(); projectionlist.add(projections.groupproperty("datecreated")); projectionlist.add(projections.rowcount()); criteria.setprojection(projectionlist); list<object[]> results = criteria.list();
result:
2013-04-27 11:08:00.0 | 32
2013-04-27 11:10:00.0 | 5
2013-04-28 15:03:27.0 | 12
i need:
2013-04-27 | 37
2013-04-28 | 12
you may find projections#sqlgroupprojection method useful. allows employ sql function date()
extracts date
form datetime
column. basically, instead of calling
projectionlist.add(projections.groupproperty("datecreated"));
use
projectionlist.add(projections.sqlgroupprojection("date(datecreated) createddate", "createddate", new string[] { "createddate" }, new type[] { standardbasictypes.date }));
Comments
Post a Comment