| Author |
Convert Date with to_char() in a select statement
|
Reggie McDougal
Ranch Hand
Joined: Sep 27, 2004
Posts: 69
|
|
Can anyone tell me what the correct syntax is for doing this I need to format the date for my app, but the syntax is wrong I get a Invalid column name exception. "SELECT product_id, product_type_id, name, description, long_description, to_char(active_from,'dd/mm/yyyy'), to_char(active_to,'dd/mm/yyyy') from product WHERE product_id = " + prodID + " and product_type_id = " + prodTypeID; This works fine when when I run it in sql. So I think JDBC does not like it. I'm using Oracle 8 Reg [ January 18, 2005: Message edited by: Reggie McDougal ] [ January 18, 2005: Message edited by: Reggie McDougal ]
|
You can never drink too much
|
 |
Shailesh Chandra
Ranch Hand
Joined: Aug 13, 2004
Posts: 1076
|
|
Reggie, give alias to columns on which you are applying to_char() and make your sql query as "SELECT product_id, product_type_id, name, description, long_description, to_char(active_from,'dd/mm/yyyy') active_from, to_char(active_to,'dd/mm/yyyy') active_to from product WHERE product_id = " + prodID + " and product_type_id = " + prodTypeID; then your JDBC will like it thanks Shailesh
|
Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
|
 |
 |
|
|
subject: Convert Date with to_char() in a select statement
|
|
|