'Filtering for a specific month in a range of a SQL database

I am trying to query (using sqlalchemy) to find temperatures for a specific month but i want the measurements for the month of june for all years in my database.

so far I have

june_temps = session.query(Measurement.tobs).\
filter(Measurement.date).all()

im stuck on the measurement.date portion and am not sure how to filter it. The database starts at 2010 and ends in the year 2017.



Solution 1:[1]

You can extract the month as an integer:

from sqlalchemy.sql import extract
...

filter(extract('month', Measurement.date) == 6)

from: https://stackoverflow.com/a/12024611/5316326

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Joost Döbken