Time math questions continued

14 views
Skip to first unread message

Robert DiFalco

unread,
Jul 22, 2015, 2:24:49 PM7/22/15
to jOOQ User Group
Okay, I am trying to write an expression like this in jOOQ.

FROM devices d
WHERE extract(hour from now() at time zone 'UTC' + d.utc_offset)
    BETWEEN 10 AND 22;

The field d.utc_offset is an Day to Second Interval. 

I understand that JOOQ does not allow me to write the "extract(hour from now() at time zone 'UTC' + d.utc_offset)" but I was hoping I could do something like the following:

Field<Date> now = DSL.createFrield("now() at time zone 'UTC'");
DSL.extract(now.plus(d.utc_offset), DatePart.HOUR).between(10, 22);

But the JOOQ documentation is vast and I couldn't figure out how to do that. I'd even be happy to do something like:

where(Field.create("extract(hour from now() at time zone 'UTC' + d.utc_offset)", Integer.class).between(10,22))

But I couldn't figure out how to do that either. Is anyone able to point me in the right direction?

Thanks! 




Robert DiFalco

unread,
Jul 22, 2015, 2:30:10 PM7/22/15
to jooq...@googlegroups.com
Ah, okay, I think I found it. I'm trying this:

DSL.field("now() at time zone 'UTC'", SQLDataType.TIMESTAMP)


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

Lukas Eder

unread,
Jul 23, 2015, 1:58:36 AM7/23/15
to jooq...@googlegroups.com
Yes, that's it

Cheers,
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+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages