nerdexam
Oracle

1Z0-061 · Question #143

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?

The correct answer is C. SELECT TO_CHAR(TO_DATE('11-oct-2007'), 'fmDdthsp "of" Month, Year') FROM DUAL. Using the TO_CHAR Function with Dates TO_CHAR converts a datetime data type to a value of VARCHAR2 data type in the format specified by the format_model. A format model is a character literal that describes the format of datetime stored in a character For example, the datetime…

Using Conversion Functions and Conditional Expressions

Question

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?

Options

  • ASELECT TO_CHAR('11-oct-2007', 'fmDdspth "of" Month, Year') FROM DUAL;
  • BSELECT TO_CHAR(TO_DATE('11-oct-2007'), 'fmDdspth of month, year') FROM DUAL;
  • CSELECT TO_CHAR(TO_DATE('11-oct-2007'), 'fmDdthsp "of" Month, Year') FROM DUAL;
  • DSELECT TO_DATE(TO_CHAR('11-oct-2007', 'fmDdspth ''of'' Month, Year')) FROM DUAL;

How the community answered

(63 responses)
  • A
    3% (2)
  • B
    5% (3)
  • C
    83% (52)
  • D
    10% (6)

Explanation

Using the TO_CHAR Function with Dates TO_CHAR converts a datetime data type to a value of VARCHAR2 data type in the format specified by the format_model. A format model is a character literal that describes the format of datetime stored in a character For example, the datetime format model for the string '11-Nov-1999' is 'DD-Mon-YYYY'. TO_CHAR function to convert a date from its default format to the one that you specify. The format model must be enclosed with single quotation marks and is case-sensitive. The format model can include any valid date format element. But be sure to separate the date value from the format model with a comma. The names of days and months in the output are automatically padded with blanks. To remove padded blanks or to suppress leading zeros, use the fill mode fm element. Elements of the Date Format Model --------------------------------------------------------------------- DY Three-letter abbreviation of the day of the week DAY Full name of the day of the week DD Numeric day of the month MM Two-digit value for the month MON Three-letter abbreviation of the month MONTH Full name of the month YYYY Full year in numbers YEAR Year spelled out (in English)

Topics

#TO_CHAR#date format models#spell out numbers#fm modifier

Community Discussion

No community discussion yet for this question.

Full 1Z0-061 Practice