aspose file tools*
The moose likes JDBC and the fly likes sql query involving dynamic date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "sql query involving dynamic date" Watch "sql query involving dynamic date" New topic
Author

sql query involving dynamic date

Shivaprasad P Kanaganahallimath
Ranch Hand

Joined: Sep 25, 2006
Posts: 48
String query="SELECT SCOREID FROM score where DATETIME between '08-apr-08' and '10-apr-08'";
works fine in java but how to give the date using any variable (String/date)


i tried like this, but doesn't work

String h="08-apr-08";
String query="SELECT SCOREID FROM score where DATETIME between "+h+" and '10-apr-08' "
this gives me invalid column name exception
could you people suggest me whats wrong?



thanks in advance


Shiva Prasad P.K.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42929
    
  68
You need to surround the "h" variable with single quotes, like you did with '10-apr-08'.
Shivaprasad P Kanaganahallimath
Ranch Hand

Joined: Sep 25, 2006
Posts: 48
Ulf Dittmer thank you so much, it's a silly mistake.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sql query involving dynamic date