Welcome to the Treehouse Community
Looking to learn something new?
Date Formatting for all date columns
-- The loans table has the following ids columns: id, book_id, patron_id; and the following date columns: loaned_on, return_by, returned_on; -- Format dates in all the loans table in the UK format without the year. For example, April 1st is 01/04.
Steven Parker216,057 Points
Are you asking about how to format dates?
There's a function for doing that, called strftime. The first argument is a string that defines the format the date will be displayed with, and the second argument is the date to be formatted.
See the SQLite documentation for a list of the possible formatting codes.
Alright it worked. Thank you. I was burnt yesterday when I was trying this.
SELECT STRFTIME("%d/%m", loaned_on) AS uk_loaned_on, STRFTIME("%d/%m", return_by) AS uk_return_by, STRFTIME("%d/%M", returned_on) AS uk_returned_on FROM loans;
I was trying all 3 columns in ONLY one STRFTIME function yesterday. I didn't know you could put in more than one STRFTIME function.