• Post Reply Bookmark Topic Watch Topic
  • New Topic

Please help me format my date for Oracle/SQL  RSS feed

 
George Larry
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • 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.
 
Bosun Bello
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
  • 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.
 
Kishore Dandu
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!