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

STRFTIME() Bummer: You may have got your params the wrong way around.

What am I missing here?

Write a query that returns the title first and the month and year it was released alias as month_year_released. Dates should look like "04/1983" for April 1983.

SELECT title, STRFTIME("%m,%y", date_released) AS month_year_released FROM movies;

3 Answers

Steven Parker
Steven Parker
231,184 Points

That message might be a bit confusing, but the instructions say, 'Dates should look like "04/1983"'.

The template shown in the query above has a comma instead of a slash for a separator, and "%y" instead of "%Y" for the year token.

I removed the comma and added date_released and got this: Bummer: Your query retrieve the dates in the correct format (%m/%Y). SELECT title, date_released,STRFTIME("%m/%y",date_released) AS month_year_released FROM movies;

Steven Parker
Steven Parker
231,184 Points

You already have a formatted "date_released", why add another one unformatted?

Also, you still need to fix the template token for the year.

Steven, I removed the first "date_released". I'm not sure what you mean by "fix the template token for the year"

I tried this: SELECT title,STRFTIME("mm/yyyy", date_released) AS month_year_released FROM movies;

And got this: Bummer: Your query retrieve the dates in the correct format

Steven Parker
Steven Parker
231,184 Points

In my original answer, I pointed out two problems in your format template:

  1. a comma instead of a slash, and
  2. "%y" instead of "%Y" for the year token.

So, instead of "%m,%y" the template should be "%m/%Y"

Thank you! I was researching https://www.sqlite.org/lang_datefunc.html just as you posted this.