简体   繁体   English

Querydsl中的date_part或EXTRACT函数

[英]date_part or EXTRACT function in Querydsl

There a way to use date_part or EXTRACT function or equivalent using querydsl? 有没有办法使用datedpart或EXTRACT函数或等效的查询语句? I'm using spring framework to build a rest aplicaiton with querydsl, and a need to make a group by date interval like 我正在使用spring框架通过querydsl建立一个休息申请,并且需要按日期间隔进行分组

QUARTER of the year (SELECT EXTRACT(QUARTER FROM TIMESTAMP '2001-02-16 20:38:40')

or 要么

SELECT date_part('day', TIMESTAMP '2001-02-16 20:38:40')

I have been search for a solution using just querydsl but withou success. 我一直在寻找仅使用querydsl的解决方案,但没有成功。

I'm using postgreSQL db. 我正在使用postgreSQL数据库。

I notice when i get a month or a year of a DataPath type the extract function is used, so i divide by 3 to get a quarter. 我注意到当我获得DataPath类型的一个月或一年时,将使用提取函数,因此我将其除以3得到四分之一。

Like this, to get the secont part of the year: 这样,要获得一年中的第二部分:

query.where(classQ.thedate.month().divide(3).ceil().eq(2))

Anyway, now i know this is a little dumb question rsrsrs,but maybe help someone 无论如何,现在我知道这是一个愚蠢的问题,rsrsrs,但也许可以帮助某人

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM