I want to get count of users grouped on a month basis from today to 365 days back. I am using groovy with Hibernate Criteria builder API . Any easy way to do this grouping? how do we specify the date format for grouping the date field by month?
Right now I have the following:
def con_cnt =Users.createCriteria().list {
like('employeeid','c_%')
between('sunsetdate', fromDate, toDate)
projections {
count('employeeid')
//groupProperty('sunsetdate')
}
}
The groupProperty('sunsetdate') groups it on a date basis and even includes the time in the grouping .. so the counts are cacluated for a very unique date & time which makes counts 1 same as the source table. How do we specify date formats in grouping using this approach? or do I have to use HQL?
Thanks in Advance.