Which SQL statement would give the required result?

You need to display the date 11-oct-2007 in words as ‘Eleventh of October, Two Thousand Seven’.
Which SQL statement would give the required result?

You need to display the date 11-oct-2007 in words as ‘Eleventh of October, Two Thousand Seven’.
Which SQL statement would give the required result?

A.
SELECT TO_CHAR(’11-oct-2007′, ‘fmDdspth "of" Month, Year’) FROM DUAL;

B.
SELECT TO_CHAR(TO_DATE(’11-oct-2007′), ‘fmDdspth of month, year’) FROM DUAL;

C.
SELECT TO_CHAR(TO_DATE(’11-oct-2007′), ‘fmDdthsp "of" Month, Year’) FROM DUAL;

D.
SELECT TO_DATE(TO_CHAR(’11-oct-2007′,’fmDdspth ”of” Month, Year’)) FROM DUAL;



Leave a Reply 15

Your email address will not be published. Required fields are marked *


user

user

why isn’t option B correct?
( fmDdspth )

Mauricio Lisbão da Silva

Mauricio Lisbão da Silva

Because the “of” is not quoted and the month and year format are in lowercase

davor

davor

Case makes no difference. Only “of” is needed.

Justyna

Justyna

B is not correct because word ‘of’ needs to be betwen double quotas
like in C.

user

user

i appreciate your help!

Eric Sacramento

Eric Sacramento

B is not correct also because the “Y” of Year is not capitalized !

sowmi

sowmi

We can give small ”y’ also in Year. Thats not an error

SQL> SELECT TO_CHAR(TO_DATE(’11-oct-2007′), ‘fmDdthsp “of” Month, year’) FROM DU
AL;

TO_CHAR(TO_DATE(’11-OCT-2007′),’FMDDTHS
—————————————
Eleventh of October, two thousand seven

Mauricio Lisbão da Silva

Mauricio Lisbão da Silva

C is correct but must have set the NLS_LANGUAGE = English

alter session set NLS_LANGUAGE = ‘ENGLISH’;

TO_CHAR(TO_DATE(’11-OCT-2007′),’FMDDSPTH”OF”MONTH,YEAR’)
———————————————————————–
Eleventh of October, Two Thousand Seven

Shixali

Shixali

Why D is not correct?

Justyna

Justyna

D is not correct because wrong order of functions TO_CHAR and TO_DATE.

Ritam Tiwari

Ritam Tiwari

C is correct but it should be like
SELECT TO_CHAR(TO_DATE(’11-oct-2007′), ‘fmDdspth “of” Month, Year’) FROM DUAL;

John

John

Nope, the result will be the same.

Larry

Larry

yes this is correct