group by date with timezones

143 views
Skip to first unread message

Nayeli Garcia

unread,
Aug 17, 2020, 7:58:34 AM8/17/20
to Querydsl
How can I  get  in querydsl  a query like this  ??

select TABLE.NAME,
extract(year from CONVERT_TZ(TABLE.DATE, '+00:00', '+06:00')) as YEAR,
extract(month from CONVERT_TZ(TABLE.DATE, '+00:00', '+06:00')) as MONTH,
extract(day from CONVERT_TZ(TABLE.DATE, '+00:00', '+06:00')) as DAY_MONTH,
count(TABLE.ID)
from TABLE
GROUP BY TABLE.NAME, YEAR, MONTH, DAY_MONTH

Thanks, 



Nathan Molinari

unread,
Aug 17, 2020, 11:08:15 AM8/17/20
to Querydsl

Hello, 

take a look in this class http://www.querydsl.com/static/querydsl/4.0.7/apidocs/com/querydsl/sql/SQLExpressions.html. It has some methods that manipulates date like dateadd, datediff, datetrunc.

You can use it like this query.orderBy(SQLExpressions.datetrunc(DatePart.day, myTable.field).desc());

i hope this help.

Nayeli Garcia

unread,
Aug 18, 2020, 6:20:08 AM8/18/20
to Querydsl
yes .. this is what I was looking for. 
Thanks. 

Reply all
Reply to author
Forward
0 new messages