jQuery in Action, 3rd edition
The moose likes Servlets and the fly likes Select date field problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Select date field problem" Watch "Select date field problem" New topic

Select date field problem

Greg Kearney

Joined: Sep 02, 2000
Posts: 7
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)?
Brian Nice
Ranch Hand

Joined: Nov 02, 2000
Posts: 195
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')
I agree. Here's the link: http://aspose.com/file-tools
subject: Select date field problem
It's not a secret anymore!