on 11-13-2008 9:37 AM
Hi All,
In my application i am not able to retrieve the data from database between two dates.
while entering the dates i am entring using :
+ "',to_date('+ fromdate+ "','DD-Mon-YYYY HH24:MI:SS'),"
as in database i have kept my fromdate type as "varchar2"
So while selecting data i have written the query as :
String sqlQuery =
"select SID,SERVER_NAME,DOWNTIMETYPE,FROMDATE,TODATE,FROMTIME,TOTIME,TIMETAKEN,DOWN_REASON from SS_UPDOWNTIME where (FROMDATE >='"
+ frmdate
+ "' OR (FROMDATE between '"
+ frmdate
+ "' and '"
+ todate
+ "')) ";
but i am not able to get the data between the two selected dates
Regards,
Anupama
Hi Anupama,
'between' wont work because you have taken dates as varchar2.
Just try like this.
Take "Date" type in database and in java take java.sql.Date
java.sql.Date sqlDefaultDate = new java.sql.Date(System.currentTimeMillis());
System.out.println("sqlDate: "+sqlDefaultDate);
// this will be in the format 2008-11-13 , So we can pass sqlDefaultDate variable to backend
Regards,
Lakshmi Prasad.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hey thanx for your help ..actually i tried this thing many times but problem here exists is that following syntax is not working:::
SQL> select
SID,SERVER_NAME,DOWNTIMETYPE,FROMDATE,TODATE,FROMTIME,TOTIME,TIMETAKEN,
DOWN_REASON
from
SS_UPDOWNTIME
where
FROMDATE >='29-Oct-08' OR (FROMDATE between '29-Oct-08' and '12-Nov-08');
when i am doing less than it is working fine..Now what the problem will be here ?
Regards,
Anupama
Hi,
Have a work around to use To_Char function. You should use To_Char function that converts date into char and then you can compare them like this
SQL> select
SID,SERVER_NAME,DOWNTIMETYPE,FROMDATE,TODATE,FROMTIME,TOTIME,TIMETAKEN,
DOWN_REASON
from
SS_UPDOWNTIME
where
TO_CHAR(FROMDATE,'DD-MON-YY) >='29-Oct-08'
Regards
Raghu
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.