PreparedStatement ignoring millisecond

Viewed 317

I'm having a problem where setTimestamp method for PreparedStatement is ignoring the millisecond. I'm using Java 1.8 and Sqlserver with JDBC Driver

String SQL = "Select x from Table where time > ?"
PreparedStatement prepStmt = con.prepareStatement(SQL);
prepStmt.setTimestamp(1,tstamp.valueOf("2018-09-14 14:47:06.827"));
ResultSet rs = prepStmt.executeQuery(); 

I got the wrong result. Seems like it executed

Select x from Table where time > 2018-09-14 14:47:06 // WRONG

instead of

Select x from Table where time > 2018-09-14 14:47:06.827 // RIGHT

How can I do setTimestamp and include millisec with it?

0 Answers
Related