python - how to query sqlalchemy by month name -
i tried this
db_session.query(paymentsmade).filter(func.strftime('%b', paymentsmade.created_at) == "august").all()
but getting error
(programmingerror) function strftime(unknown, timestamp without time zone) not exist line 3: strftime('%b', paymentsmade.created_at) = 'august' ^ hint: no function matches given name , argument types. might need add explicit type casts.
and saving date created_at = datetime.utcnow()
you want call postgressql function to_char
, not python datetime
function strftime
:
db_session.query(paymentsmade) \ .filter(func.to_char(paymentsmade.created_at, "fmmonth") == "august")
Comments
Post a Comment