Reputation: 77
I retrieve timestamp type data from the mysql table. but I just need to return only the date part of this timestamp. Tried in convering timestamp to a date data type. But in jooq this gives some errors.Here is what I retrieve
Field<Timestamp> transaction_date = LINKLK_TRANSACTIONS.MODIFIED_AT.as("transaction_date");
Upvotes: 0
Views: 5804
Reputation: 221370
This cannot work:
Field<Timestamp> transaction_date = LINKLK_TRANSACTIONS.MODIFIED_AT.as("transaction_date");
All you're doing is renaming your column to a different name that happens to contain the name "date". You have to use MySQL's date()
function, for instance
Field<Date> transaction_date = DSL.date(LINKLK_TRANSACTIONS.MODIFIED_AT);
Or you can cast your Field
:
Field<Date> transaction_date = LINKLK_TRANSACTIONS.MODIFIED_AT.cast(Date.class);
There are many other options to do the same, but the above will be sufficient for your particular use-case.
Upvotes: 2