Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Select date field problem

 
Greg Kearney
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Database Oracle 8i.
My program is a calendar JSP where mm/dd 1 through 9 are a single digit.
When I use
<%! public final static String GET_DAYS_EVENTS_QUERY =
"SELECT name, event_id, start_date FROM Events " +
"where to_char(start_date,'yyyy') = ? " +
" and to_char(start_date, 'mm') = ? " +
" and to_char(start_date, 'dd') = ? " +
"ORDER BY event_id"; %>
<%
the database is looking for two digits to be placed in mm/dd. Is there another way to write the select statement where the database will understand a single digit mm/dd, example(3-1-2001)?
Thanks
 
Brian Nice
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using a function like LPAD:
and to_char(start_date, 'mm') = lpad(month,2,'0')
and to_char(start_date, 'dd') = lpad(day,2,'0')
HTH
Brian
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic