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
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 Parker228,978 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.