Comparing 2 Dates!!!
hi guys,
i have to compare 2 dates, out of which one is retrieved from the database and the other one is the current system time.
i have to compare the 2 dates..if the date retrieved from the DB is equal to the system date, it should return
"already logged in"
else
it should accept the values like ID,date and time, and enter in the database..
both the dates compared are sql dates..
heres a part of my code..
pst2 = con.prepareStatement("SELECT logintime,day FROM login where empid=? order by day asc");
pst2.setString(1,eid);
rs2 = pst2.executeQuery();
while(rs2.next())
{
logtime=rs2.getTime("logintime");
day=rs2.getDate("day");
}
System.out.println(day);
if(day.compareTo(datt)>0)
{
pst1=con.prepareStatement("insert into login(empid,logintime,day) values(?,?,?)");
pst1.setString(1,eid);
pst1.setString(2,time);
pst1.setDate(3,datt);
int rowsInserted=pst1.executeUpdate();
}
else
{
System.out.println("u have already logged in");
}
please kindly reply to my query..
thanks in advance..

