How to perform date operations in hibernate

前端 未结 8 1058
既然无缘
既然无缘 2020-12-10 03:00

I want to perform data time operations using hibernate HQL.

I want to add and subtract two dates as well as I want to subtract 1 year or 1 month from a particular da

8条回答
  •  轮回少年
    2020-12-10 03:39

    Postgres users...

    registerFunction("dateadd", new SQLFunctionTemplate(StandardBasicTypes.DATE, "(?1 + INTERVAL ?2)"));
    

    with SQL usage like:

    now() < dateadd(:mydate, '-1 day')
    

提交回复
热议问题