Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Syntax error converting datetime from character string.

 
S bitz
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to insert some values in a database.I'm using prepared statements and this is my query


startDate and returnDate are of the format "YYYYMMDD"

This throws this error : Syntax error converting datetime from character string.

but when i change the query to

pstmt.setString(4,"20060905") this works fine.

I'm using SQL Server 2000.
Can anyone tell me how this can be fixed?

Thanks
Bitz
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
  • Convert Your String date to java.util.Date or Java.sql.Date
  • Set them as date in preparedStaement, NOT as String






  • Shailesh
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic