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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -