Prashant Bhat
unread,Oct 5, 2012, 4:47:08 AM10/5/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to h2-da...@googlegroups.com
Hi,
We are using H2 Database in our application, but based on requirement of some users PostgreSQL is used. And we use JPA to be compatible with both the databases, but some of the reports use native sql queries. One of the queries that uses EXTRACT(WEEK FROM dateColumn) is not compatible with H2, as it supports WK and WW which are not supported in Postgresql.
We've made the following change to Function.java to add this option and the attached patch also updates help.csv files. I hope this can be integrated into H2 codebase.
Thanks & Best Regards,
Prashant
Index: src/main/org/h2/expression/Function.java
===================================================================
--- src/main/org/h2/expression/Function.java (revision 4381)
+++ src/main/org/h2/expression/Function.java (working copy)
@@ -129,6 +129,7 @@
DATE_PART.put("SQL_TSI_WEEK", Calendar.WEEK_OF_YEAR);
DATE_PART.put("WW", Calendar.WEEK_OF_YEAR);
DATE_PART.put("WK", Calendar.WEEK_OF_YEAR);
+ DATE_PART.put("WEEK", Calendar.WEEK_OF_YEAR);
DATE_PART.put("DAY", Calendar.DAY_OF_MONTH);
DATE_PART.put("DD", Calendar.DAY_OF_MONTH);
DATE_PART.put("D", Calendar.DAY_OF_MONTH);