More DBA job interview questions and answers at
http://dba.fyicenter.com/Interview-Questions/
(Continued from previous question...)
I want to fetch a date column with the 'DD-MMM-YYYY' format. Can I do it in a single query?
Q: I want to fetch a date column with the 'DD-MMM-YYYY' format. Can I do it in a single query? I tried to run the following SQL, but got an error:
SELECT CHAR(T1.COL_DT ,'DD-MMM-YYYY'),
FROM TABLE1 T1;
Any ideas?
A: You are not using the CHAR function correctly. When using CHAR to convert a date column into a character representation, the second parameter can only be one of the following: ISO, USA, EUR, JIS, or LOCAL. Consult Table 1 for the format to which each of these corresponds.
To return the data in the format you are requesting, DD-MMM-YYYY, you will need to install a local date format routine. Get in touch with your system programmer to discuss whether this is feasible and how to do it.
(Continued on next question...)