jooq的LocalDateTime转化成LocalDate

jooq:

tableName.COMPLETION_TIME.cast(LocalDate.class);

 

mysql sql

// and date_format(cms_system_progress_fillin_cycle.start_time, '%Y-%m-%d') = date_format(sysdate(), '%Y-%m-%d')
jooq:
.and(DSL.field("date_format({0}, {1})", SQLDataType.VARCHAR, cms_system_progress_fillin_cycle.START_TIME, DSL.inline("%Y-%m-%d"))
.eq(DSL.field("date_format({0}, {1})", SQLDataType.VARCHAR, currentTimestamp(), DSL.inline("%Y-%m-%d"))))

mysql sql
//        and date(sysdate()) < date(a.completion_time)
// and date(sysdate()) >= date_sub(date(a.completion_time), interval 3 day)
jooq:
.and(DSL.field("date_format({0}, {1})", SQLDataType.VARCHAR, currentTimestamp(), DSL.inline("%Y-%m-%d"))
.lt(DSL.field("date_format({0}, {1})", SQLDataType.VARCHAR, cms_system_progress_fillin_cycle.COMPLETION_TIME, DSL.inline("%Y-%m-%d"))))
.and(DSL.field("date_format({0}, {1})", SQLDataType.VARCHAR, currentTimestamp(), DSL.inline("%Y-%m-%d"))
.ge(DSL.field("date_format({0}, {1})", SQLDataType.VARCHAR, DSL.field(cms_system_progress_fillin_cycle.COMPLETION_TIME).sub(3), DSL.inline("%Y-%m-%d"))))

mysql sql
//        and date(sysdate()) < date(t.completion_time)
// and date(sysdate()) >= date_sub(date(t.completion_time), interval 3 day)
jooq:
.and(DSL.currentLocalDate().lt(cms_system_progress_additional_fillin.COMPLETION_TIME.cast(LocalDate.class)))
.and(DSL.currentLocalDate().ge(DSL.localDateTimeSub(cms_system_progress_additional_fillin.COMPLETION_TIME, 3, DatePart.DAY).cast(LocalDate.class)))



posted on 2020-08-06 11:08  小甜瓜安东泥  阅读(491)  评论(0编辑  收藏  举报