Convertion of Date Format using SQL query in a shell script

When I write

Select date_field from TableA fetch first row only

I am getting the output as 09/25/2009.

I want to get the output in the below format

2009-09-25 i.e., MM-DD-YYYY. Please help

Hi.

Use to_char to get the format you want.

to_char( date_field, 'YYYY-MM-DD' )

http://www.techonthenet.com/oracle/functions/to_char.php

I am getting the error as "SQL0440N No authorized routine named "TO_CHAR" of type "FUNCTION" having
compatible arguments was found. SQLSTATE=42884
"

Please help

The TO_CHAR function is perhaps specific to ORACLE.
You haven't specify wich database you are using.

Jean-Pierre.

Thanks for the response.I am using DB2 Database. Please help with the command for the same

Try :

Select CHAR(date_field, ISO)  from TableA fetch first row only

The date is displayed with the format YYYY-MM-DD

Jean-Pierre.

Hi aigles..
Thanks a lot!! it is working..May I know what is "ISO" ?

International Standards Organisation

Download DB2 SQL Reference

Jean-Pierre.