Arul
Arul

Reputation: 1

Oracle Query is returning value when setting value to it, but not returning value when passing date value

My below query is not returning any values when i pass the START_DATE and END_DATE as parameter to my oracle procedure. But when i set actual date in the query i am getting results. Kindly help me what is the mistake i have done here. Thanks in advance.

SELECT INCIDENT_ID 
FROM INC_SM1 I 
WHERE 
    I.CLOSE_TIME >= TO_DATE(START_DATE,'DD-MON-YYYY HH24:MI:SS')
AND I.CLOSE_TIME < TO_DATE(END_DATE,'DD-MON-YYYY HH24:MI:SS')

The below query is returning values, when I run my procedure

SELECT INCIDENT_ID 
FROM INC_SM1 I 
WHERE 
    I.CLOSE_TIME >= TO_DATE('01-JUL-2013 00:00','DD-MON-YYYY HH24:MI') 
AND I.CLOSE_TIME < TO_DATE('01-AUG-2013 00:00','DD-MON-YYYY HH24:MI')

Note: My input to procedure is TO_DATE('01-JUL-2013 00:00','DD-MON-YYYY HH24:MI')

Upvotes: 0

Views: 74

Answers (1)

Sebas
Sebas

Reputation: 21532

Since you're already forcing the date format, you can use the following query instead:

SELECT INCIDENT_ID 
FROM INC_SM1 I 
WHERE 
    I.CLOSE_TIME >= START_DATE
AND I.CLOSE_TIME < END_DATE

Upvotes: 1

Related Questions