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

Development Tools Database Foundations Reading Data from Databases with SQL Querying Tables

Diego Salazar
Diego Salazar
2,206 Points

How could I use a where datetime.month> January and datetime.year>2015 or something like this

How could I do this selection of only year and month of a datetime in a select

1 Answer

There's a variety of ways to do it.

  1. You could reference the date - if you're looking for all records in 2015 use > 12/31/2015 on the date field.
  2. Month returns digit representations of dates - so you don't look for january - you look for 1