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 trialNick Manring
11,369 Pointswhy do we have to use a capital "Y" when doing date formatting. why is it only the year that is capital. so frustrating
I'm just curious as to why this format condition is required for year. I know when I use application like Excel or other similar programs and do formatting with functions or programming, it doesn't matter. Here, you clearly ask for the capital Y in the last code challenge of this section. I was really annoyed to find this to be why I was getting it wrong over and over.
Anyway, glad I know now. Is it like this in all SQL environments?
Thanks
2 Answers
Kevin Korte
28,149 PointsBecause %y would give you the two digit date, i.e. 2016 would be just 16.
You can see here: http://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_date-format
All of the options that sql gives you to format dates. It's likely that most all sql databases will use the same formatters, or at least be very similar, but always be sure to check that sql database's documents for the same version you're using to be sure.
Nick Manring
11,369 PointsAh.. interesting. Ok. I figured that would be y, yy, yyyy, or the same in caps. I thought that was pretty universal but i guess not! :)
thanks!
Joshua Kaufman
19,193 PointsIt is "universal", in the sense that this isn't the only language that requires this type of output to display the date in 4 digits vs. 2 digits. For example, PHP also requires using uppercase Y instead of lowercase y to display the Date(). I know this isn't entirely related, but you can see what I mean by following this link http://php.net/manual/en/function.date.php