Databases Reporting with SQL Date and Time Functions Formatting Dates and Times

Date Datatypes Task

Query is supposed to return the titles of the movies and just the month and year they were released. I tried: SELECT title, STRFTIME (%m/%y, "date_released") AS "month_year_released" FROM movies; but it said there was something wrong with my SQL code. I'll admit I was kinda guessing I could use a column name as <time string>. Please help!

4 Answers

KRIS NIKOLAISEN
KRIS NIKOLAISEN
54,369 Points

Some hints:

  • The format string will be enclosed in quotes
  • The field used for timestring will not be enclosed in quotes
  • Use capital %Y for 4 digit year
rydavim
MOD
rydavim
Treehouse Moderator 18,241 Points
                      /* str in quotes, year syntax is capital - %Y */
SELECT title, STRFTIME (%m/%y, "date_released") AS "month_year_released" FROM movies
                     /* date_released field seems to forgive quotes, but syntax shouldn't have them */

Nice work, you've almost got it! Happy coding!

Thank you very helpful! Much appreciated!

Thanks so much! Very helpful!