I'm using SQLAlchemy with python and i want to select date from column type timestamp, to do this query:
SELECT DATE(`record_date`) FROM Users
I made this code by sql alchemy but it will return the timestamp:
session.query(Users.record_date).all()
How can i do it?
give an alias
SELECT DATE(`record_date`) as record_d FROM Users
then use this
session.query(Users.record_d).all()
If want do it directly then ,try this
your_dates = session.query(cast(Users.record_date, DATE)).all()
EDIT:
your_dates = session.query(func.DATE(Users.record_date)).all()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With