• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Change your query to use a PreparedStatement and bind your dates to parameters. This will remove the formatting mismatch.
 
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic