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 For Reporting

Sean Flanagan
Sean Flanagan
33,235 Points

My solution for Format Output

Hi. This is my solution for the third challenge:

SELECT STRFTIME("%d/%m", loaned_on), 
       STRFTIME("%d/%m", return_by),
       STRFTIME("%d/%m", returned_on) FROM loans;

The result of this was to change the column names but I was able to format all the date columns as Andrew Chalkley suggested. Is this what he was looking for?

Thanks in advance!

1 Answer

You could have used an alias ('as'). Sometimes this makes column names like loaned_on a little bit more friendly to read in a report.

SELECT STRFTIME("%d/%m", loaned_on) as 'Loan Date',
              STRFTIME("%d/%m", return_by) as 'Due Date'
              STRFTIME("%d/%m", returned_on) as 'Return Date' FROM loans;

Aliases can be useful when: There are more than one table involved in a query Functions are used in the query Column names are big or not very readable Two or more columns are combined together -> (calculations)