Skip to content

Instantly share code, notes, and snippets.

@carlosmontoya89
Forked from danielthiel/SQLAlchemy_cast.py
Created February 3, 2020 21:37
Show Gist options
  • Select an option

  • Save carlosmontoya89/6f3b3a4d89a7343c87967eb858d95a38 to your computer and use it in GitHub Desktop.

Select an option

Save carlosmontoya89/6f3b3a4d89a7343c87967eb858d95a38 to your computer and use it in GitHub Desktop.
SQLAlchemy: filter by date for an datetime field(does not work with SQLite, with PostgreSQL it works fine)
from datetime import date
from sqlalchemy import cast, DATE
Match.query.filter(cast(Match.date_time_field, DATE)==date.today()).all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment