This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Convert DateTime Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Convert DateTime Error" Watch "Convert DateTime Error" New topic
Author

Convert DateTime Error

Jerome Donaldson
Greenhorn

Joined: May 11, 2005
Posts: 13
Complete newbie to java

I am trying to do a convert from a parameter to a datetime stamp. Here is my code:
... bus_start_date between (CONVERT(DATETIME,\'args[3]\', 102)) and (CONVERT(DATETIME,\'args[4]\', 102))) ...
Exception in thread "main" java.sql.SQLException: Syntax error converting datetime from character string.

When I enter a hard coded sting instead of the parms it works ex('2008-01-02 00:00:00')

Can ANY one help please,

Thank you in advance
Lukasz Bajzel
Greenhorn

Joined: Dec 03, 2007
Posts: 26
It has nothing to do with Java. You have an SQL syntax error here. What database are you using? Whatever it may be, the arg is not translating into actual value here.

Sincerely
Your friends at www.javaadvice.com
Jerome Donaldson
Greenhorn

Joined: May 11, 2005
Posts: 13
MSSQL Server

I cant seem to be able to get the syntax right. Can yu help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Convert DateTime Error
 
Similar Threads
How to insert a data of datetype timestamp into Sqlserver2000
time conversion
Joda DateTime
unable to retrieve timestamp in my servlet
problem while insert date data in mysql