I am trying to execute my query through Java like this:
public ResultSet execSumStatment2() throws SQLException{
String query = \"Select SUM(A) as NCCSeptemb
In SQL Developer ..Go to Preferences-->NLS-->and change your date format accordingly
You can try this:
Select To_date ('15/2/2007 00:00:00', 'DD/MM/YYYY HH24:MI:SS'),
To_date ('28/2/2007 10:12', 'DD/MM/YYYY HH24:MI:SS')
From DUAL;
Source: http://notsyncing.org/2008/02/manipulando-fechas-con-horas-en-plsql-y-sql/
You can use
Select to_date('08/15/2017 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM') from dual;
If you are using it in an SP then your variable datatype should be Varchar2
and also in your ado.net code the datatype of your input parameter should be
OracleDbType.Varchar2
Basically I had to put a DateFrom and DateTo filter in my SP so I passed dates as String in it.
Note: This is one of the solution which worked for me, there could be more solutions to this problem.
What you have written in your sql string is a Timestamp
not Date
. You must convert it to Date
or change type of database field to Timestamp
for it to be seen correctly.
You can try as follows it works for me
select * from nm_admission where trunc(entry_timestamp) = to_date('09-SEP-2018','DD-MM-YY');
OR
select * from nm_admission where trunc(entry_timestamp) = '09-SEP-2018';
You can also try using to_char but remember to_char is too expensive
select * from nm_admission where to_char(entry_timestamp) = to_date('09-SEP-2018','DD-MM-YY');
The TRUNC(17-SEP-2018 08:30:11) will give 17-SEP-2018 00:00:00 as a result, you can compare the only date portion independently and time portion will skip.
I think you should not rely on the implicit conversion. It is a bad practice.
Instead you should try like this:
datenum >= to_date('11/26/2013','mm/dd/yyyy')
or like
datenum >= date '2013-09-01'