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 trialDaniel Alarcon
8,019 PointsSince operators were used on dates (i.e. <, >), I imagine other operators can be used as well, such as (+, -, * or /)
I imagine this can be done because computers internally assign numbers to dates... (?) And I can't imagine other cases other than addition or substraction to compare a given date, maybe division and finding out if a year is a leap year
2 Answers
Steven Parker
231,261 PointsDates can be compared directly, but to perform calculations on them, you'll first need to convert them to julianday or make use of the modifiers available in the date() function.
There's a video about Calculating Dates in the Reporting with SQL course.
Daniel Alarcon
8,019 PointsThanks Steven. Good to know. I was aware that operations could be performed on dates. It's useful to learn about the julianday conversion. I knew other systems/software handled dates too and that operations were viable, but I wasn't exactly sure how MySQL did that. I already took the Reporting with SQL course, so maybe I missed references to julianday conversion but I do remember date modifiers were mentioned.