• 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

Please help me format my date for Oracle/SQL

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a jsp page where a user enters a date and that date is used in a SQL query... or rather, it's supposed to be used in a query, but I haven't been able to get it to work.
I have them enter it in the following format:
dd/mm/yy (06/07/02)
For Oracle I need to change that to this format:
dd-MON-yy (06-JUN-02)
Please help me do this.
Thank you.
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use the methods of the calendar class to to get the month name. Or you can just create a HashMap with the month numbers as the key and the mongh names as the values and go from there.
 
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think it is mandatory to use dd-MON-yy for the retrieve based on a Date field in the oracle database.
I use some thing like:
table1.ACTIVITY_DATE = to_date( ?, 'YYYYMMDD');
params.add(reportDate);
Here report date is similar to the date you are talking about. All I do is convert or save the value you get from jsp as a string and invoke the sql as above. This way you don't need to go through headaches of converting to month name etc.
Always a novice,
Kishore.
reply
    Bookmark Topic Watch Topic
  • New Topic