month() function and year() function in postgresql through jpa2
问题 How to get the month and year of a postgresql date field using jpa2 criteria query or jpql? Has anybody done this? 回答1: Use this: FUNC('MyFunc', a, b, c) Example: SELECT FUNC('to_char', current_date, 'month') 回答2: A few examples, how to extract the month from a date or timestamp in PostgreSQL: select to_char(now(), 'month'); select to_char(now(), 'MM'); select extract('month' from now()); select date_part('month', now()); Just read the manual. 回答3: With JPA criteria API (tested only with