我正在執行下面的SQL查詢,但查詢不會返回任何行,即使對應於所選日期的條目存在於表中。Oracle SQL where子句針對時間戳列
Date getdatetemp = datechooser.getDate(); // getting the date selected by user
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
java.sql.Date extdate=new java.sql.Date(getdatetemp.getTime());
String getdate=sdf.format(extdate);
String sql="SELECT * from registration_timestamp where timestamp_registered=TO_DATE('"+getdate+"','dd/MM/yyyy')";
PreparedStatement pst=connection.prepareStatement(sql);
ResultSet res=pst.executeQuery();
pst.close();
res.close();
更好地向我們展示;在DB中插入代碼也。 – 2013-02-16 18:06:07
從registration_timestamp中選擇to_char(timestamp_registered,'yyyy/mm/dd hh24:mi:ss');檢查DB存儲的日期? – 2013-02-16 18:08:37
@KanagaveluSugumar查詢返回** 2013/02/03 11:03:16 ** – 2013-02-16 18:13:15