Naveen
November 22, 2018, 7:55am
1
When I trying fetch the details from the Database using Date Field i am getting the below error.
Query running:
org.hibernate.Query qry =
session.createQuery("select Name, DataID from ColumnDetails where ParentID = '2003' TO_DATE('2015-09-01', 'YYYY-MM-DD AND TO_DATE('2015-09-01 23:59:59', 'YYYY-MM-DD HH24:MI:SS')");
Error Getting:
Nov 22, 2018 12:35:14 PM org.hibernate.hql.internal.ast.ErrorCounter reportError
ERROR: line 1:72: unexpected token: TO_DATE
Nov 22, 2018 12:35:14 PM org.hibernate.hql.internal.ast.ErrorCounter reportError
ERROR: line 1:72: unexpected token: TO_DATE
line 1:72: unexpected token: TO_DATE
Can you please help me to resolve this issue ASAP.
Let me know if you need any additional information as well.
vlad
November 22, 2018, 8:07am
2
You miss an AND
between 2003 and TO_DATE which alao should also be used in a comparison operator.
Maybe you wanted something like this:
org.hibernate.Query qry =
session.createQuery("select Name, DataID from ColumnDetails where ParentID = '2003' AND myDate >= TO_DATE('2015-09-01', 'YYYY-MM-DD') AND myDate <= TO_DATE('2015-09-01 23:59:59', 'YYYY-MM-DD HH24:MI:SS')");
Naveen
November 22, 2018, 8:10am
3
Sorry I gave the wrong URL,
Please find the correct one, getting the same error:
Query qry = (Query) session.createQuery(“select Name, DataID from ColumnDetails where ParentID = ‘2003’ and ModifyDate BETWEEN TO_DATE(‘2015-09-01’, 'YYYY-MM-DD AND TO_DATE(‘2015-09-01 23:59:59’, ‘YYYY-MM-DD HH24:MI:SS’)”);
Let me know if you need any additional information.
vlad
November 22, 2018, 8:13am
4
That happens because the JPQL query is badly formatted since the TO_DATE
function is supported by many SQL databases.
Naveen
November 22, 2018, 8:22am
5
Hi
Can you please help me on this ? i am not able to understand what is registration?
My requirement is
I need to select one column from the database using yesterday’ s date:
Can you help me to write query for this in hibernate.