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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 39547
    
  27
You need to surround the "h" variable with single quotes, like you did with '10-apr-08'.


Ping & DNS - updated with new look and Ping home screen widget
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
 
Similar Threads
Hibernate Date Issue
String to Date conversion
problem related to timestamp
Microsoft SQL - get time
oracle date between