Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Jonatan Spahn6,362 Points
SQL Stage 4: Practice problem.
So it asks to
-- Format dates in all the loans table in the UK format without the year. For example, April 1st is 01/04.
This is my code:
SELECT *, STRFTIME("%d/%m", "loaned_on") AS UK_format FROM loans;
but is there away to use STRFTIME and change the loaned_on and the return_by columns all in the UK format or do you have to do each one separate?
Steven Parker208,474 Points
STRFTIME operates on one timestring.
So you would need to use it on each column that you want to format separately.
Also, you don't need quotes around the column name.
Samandar Mirzayev11,834 Points
SELECT id,book_id,patron_id,STRFTIME("%d/%m", "loaned_on") AS "UK date loaned", STRFTIME("%d/%m","return_by") AS "UK date return by", STRFTIME("%d/%m","returned_on") AS "UK date return" FROM loans;