Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

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
rydavim
18,814 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!