aspose file tools*
The moose likes JDBC and the fly likes Syntax error converting datetime from character string. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Syntax error converting datetime from character string." Watch "Syntax error converting datetime from character string." New topic
Author

Syntax error converting datetime from character string.

S bitz
Ranch Hand

Joined: Jan 20, 2006
Posts: 80
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

Joined: Aug 13, 2004
Posts: 1081

  • Convert Your String date to java.util.Date or Java.sql.Date
  • Set them as date in preparedStaement, NOT as String






  • Shailesh


    Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Syntax error converting datetime from character string.