I have a query which use a date I work with oracle
but I have a problem in format of date
when I run my query I have an error
this my query test:
select NUM_REQUEST,
from REQUEST_TEST
where REQUEST_DATE between TO_DATE('Thu Nov 07 00:00:00 CET 2013','MM/dd/yyyy hh:mm:ss a') and TO_DATE('Mon Dec 23 00:00:00 CET 2013','MM/dd/yyyy hh:mm:ss a'))
I have an error in foramt of date using to_date function
when I try with this query and I have a correct result
select NUM_REQUEST,
from REQUEST_TEST
where REQUEST_DATE between to_timestamp_tz('Thu Nov 07 00:00:00 CET 2013','Dy Mon dd hh24:mi:ss TZR yyyy') and to_timestamp_tz('Mon Dec 23 00:00:00 CET 2013','Dy Mon dd hh24:mi:ss TZR yyyy'))
but when I test in my application with :
String sqlQuery = "select NUM_REQUEST, from REQUEST_TEST" +
" where REQUEST_DATE between to_timestamp_tz('Thu Nov 07 00:00:00 CET 2013','Dy Mon dd hh24:mi:ss TZR yyyy') and to_timestamp_tz('Mon Dec 23 00:00:00 CET 2013','Dy Mon dd hh24:mi:ss TZR yyyy')) ";
Query query = this.getSession().createSQLQuery(sqlQuery);
I have this error :
ORA-01846: ce n'est pas un jour de semaine valide
org.hibernate.exception.DataException: could not execute query
I have for example in my column REQUEST_DATE this data 29-NOV-13 and when I edit this column I have this format for example : friday, 29 Novembre 2013 00:00:00 o'clock CET
Thu Nov...) is completely different to the date format model you're providing to the same function (MM/DD/...). Not really surprising that it's complaining. You may need to be working withtimestamprather thandateif you're passing in a time zone. You seem to have a trailing comma on the first line as well. It's generally useful to show the actual error you get.