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

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -