Multiple choice technology databases

Which of the following functions is used to convert a date to a string in the specified format?

  1. to_date(string,format)

  2. to_char(date,format)

  3. to_date(date,format)

  4. to_number(string,format)

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The to_char function converts a date value to a string representation in the specified format. Option B is the correct PostgreSQL and Oracle function. Option A (to_date) converts string to date, option C is an invalid signature, and option D converts strings to numbers, not dates to strings.