I am getting correct result when I query from Microsoft Query but when I query from SQLPLUS(Oracle) I get incorrect result.
Here is Microsoft Query (Result shows correct from June 12th 3 PM to June 13 12 AM.
SELECT
NAME,
CIM,
NUM_of_People,
STARTDATETIME
From Table
WHERE (SUSTAINED_FLAG=1)
AND (PLANNED_FLAG=0)
AND (STARTDATETIME>{ts '2013-06-12 04:00:00'}
And STARTDATETIME<{ts '2013-06-13 12:00:00'})
In Oracle I am using this clause which gives me wrong result.
it is showing
query result from dates only after June 13 12:AM to 12 PM.
SELECT
NAME,
CIM,
NUM_of_People,
TO_CHAR(STARTDATETIME,'MM/DD/YYYY HH:MI:SS') As STARTDATETIME
FROM OBVWH.
where BETWEEN To_Date(to_char(STARTDATETIME, 'DD-MON-YYYY')) >= To_Date('06/12/2013 16:00:00','MM/DD/YYYY HH24:MI:SS')
and To_Date(to_char(STARTDATETIME, 'DD-MON-YYYY')) <= To_Date('06/13/2013 12:00:00','MM/DD/YYYY HH24:MI:SS')
and sustained_flag = 1 and planned_flag = 0 ORDER BY STARTDATETIME ASC