I wants to check the CurrentDate(MM/DD/YYY format) with the date in MSSQL Server Database, but my query is not giving the prper result Anybody knows how to get CurrentDate(in MM/DD/YYYY format Time is not required) in Java, so that can use in my query i am giving my code below
Connection con1; PreparedStatement stat1;
con1=DriverManager.getConnection ("jdbc:odbc:ENABLE","elearn","hclinfo"); stat1=con1.prepareStatement("select Conf_Id from Conf_Ann where Conf_Cxo=? and Conf_Dt=?"); stat1.setString(1,UData.Uid); stat1.setDate(2,new java.sql.Date(new java.util.Date().getDate())); ResultSet result1=null; result1=stat1.executeQuery();
I don't think there is any format the Date class stores the date. It stores in milliseconds. Anyway why you need to format it? What is the database you are using?
I am using MS SQL Server 2K,Actually what is happening is,my table is storing date only (ie 9/23/2003 will be rounded to 9/23/2003 00:00:00) not date with time.So when i am comparing the Date in my Table with current date from java with time (ie, 9/23/2003 Vs 9/23/2003 11:30:58) obviously it will not be equal, i need to compare dates only, i am not considering time
I am using MS SQL Server 2K,Actually what is happening is,my table is storing date only (ie 9/23/2003 will be rounded to 9/23/2003 00:00:00) not date with time.So when i am comparing the Date in my Table with current date from java with time (ie, 9/23/2003 Vs 9/23/2003 11:30:58) obviously it will not be equal, i need to compare dates only, i am not considering time
i want to chek whether Today's date is equal to or not equal to the date in database, it should not consider the time
I am using MS SQL Server 2K,Actually what is happening is,my table is storing date only (ie 9/23/2003 will be rounded to 9/23/2003 00:00:00) not date with time.So when i am comparing the Date in my Table with current date from java with time (ie, 9/23/2003 Vs 9/23/2003 11:30:58) obviously it will not be equal, i need to compare dates only, i am not considering time
i want to chek whether Today's date is equal to or not equal to the date in database, it should not consider the time
I don't really understand the question. You may try to create a Date object starting with Calendar.getInstance() and then setting in this Calendar object only the times you require. Eg.
Calendar now = Calendar.getInstance();
now.set(Calendar.MINUTES,0);
....
Date datNow = now.getTime();
in Oracle there are functions like to_date() and to_char() for date manupulation. I used those to cut off the time part and make a Srting comparison. Is there any functions equal to those in MS SQL?