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

Sean Flanagan
Sean Flanagan
33,224 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!

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)