Best way to subtract minutes from a timestamp?

7 views
Skip to first unread message

dlsdi...@gmail.com

unread,
Apr 2, 2018, 6:29:42 AM4/2/18
to jOOQ User Group
Hello all I'm trying to work on a conditional statement where I get the MAX time from each table but I have to minus two minutes from the other.

I have tried using dateSub unfortunately it just returns to me a Date. TimeStamp also does not work for dateSub so I am quite lost.

Any help would be highly appreciated.

Here is the code I have so far:

.and(MEASUREMENT.TIME
         .between(context.select(max(AGG_MEASUREMENT_MINUTE.TIME)).from(AGG_MEASUREMENT_MINUTE).asField())
         .and(context.select(dateSub(max(MEASUREMENT.TIME).cast(Date.class),2,DatePart.MINUTE)).from(MEASUREMENT).asField())
    )


Lukas Eder

unread,
Apr 3, 2018, 4:29:34 AM4/3/18
to jooq...@googlegroups.com
Hello,

Use DSL.timestampAdd():

I guess we should add timestampSub() to be more consistent with dateSub(). I've created a feature request for this:

Hope this helps,
Lukas

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Dioquino

unread,
Apr 3, 2018, 4:46:00 AM4/3/18
to jOOQ User Group
This helps a lot! Thanks so much!
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages