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
201,931 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
201,931 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
201,931 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.