Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in date comparing with db2 database,query is not executing

 
saswat rashmi
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everyone

i have one jsp page two text box
1. one for start date
2.second for end date
and for date selection have used datepicker

user selects the start date and end date .then clicks on view button
then i am retrieving these two dates on next jsp page .uptp here is ok

here i want display related data from db2 databse between these two dates(start date and end date)on next jsppage

but it is giving error my db2 dtabse uses the format of YYYY-MM-DD

the query i am not able execute

String strsql ="select voucher_master.VOUCHER_TYPE,voucher_master.VOUCHER_NO,dd_master.CHQ_DD_NO,dd_master.DD_DATE from voucher_master,dd_master Where voucher_master.VOUCHER_ID = dd_master.VOUCHER_ID and dd_master.DD_DATE >=" + fromdate + " and dd_master.DD_DATE <=" + todate + "";
it is giving error

please help me
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change your query to use a PreparedStatement and bind your dates to parameters. This will remove the formatting mismatch.
 
Paul Campbell
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or... you could just use the SQL to_date function

to_date(my_field,"date_format of my field)
[ October 10, 2007: Message edited by: Paul Campbell ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic