-
-
Save danielthiel/8374607 to your computer and use it in GitHub Desktop.
from datetime import date | |
from sqlalchemy import cast, DATE | |
Match.query.filter(cast(Match.date_time_field, DATE)==date.today()).all() |
Hi guys,
For SQLite, I'm using the func.DATE()
function:
from sqlalchemy import func
session.query(db.Transaction).filter(func.DATE(db.Transaction.datetime) == date.today())
Hi guys,
For SQLite, I'm using thefunc.DATE()
function:from sqlalchemy import func session.query(db.Transaction).filter(func.DATE(db.Transaction.datetime) == date.today())
I've been pulling my hair out trying to solve this, but your suggestion worked perfectly. Thanks!
@bhandler.route('/sbooking', methods=['GET', 'POST'])
def sbooking():
form = SBookingForm()
if form.validate_on_submit():
s_date = form.bdate.data
sr_date = s_date.strftime("%Y-%m-%d %H:%M:%S")
if form.bresort.data=='Sona Grand':
rec = db.session.query(Booking).filter(Booking.bresort == 'Sona Grand'
).filter(Booking.bauth == 'Yes'
).filter(Booking.bdate == sr_date)
return render_template('sbookingrec.html', rec=rec, sr_date=sr_date)
return render_template('sbooking.html', title='Date Status',
form=form, legend='Date Status')
sir when comparison with date return nothing but use less then and greater then code is working
problem with date comparison is not working
Thank you Jonatan. func.DATE() works.
I've opened an issue sqlalchemy/sqlalchemy#5104
Hi guys,
For SQLite, I'm using thefunc.DATE()
function:from sqlalchemy import func session.query(db.Transaction).filter(func.DATE(db.Transaction.datetime) == date.today())
It worked! Thank you sooo much!
👺it doesn't work with even postgress for me
This worked for me:
from sqlalchemy import func
table_db = Youtable.query.filter(func.DATE(Youtable.date_bd) == your_date)
Same problem here. Might have to do with Sqlite doesn't have a DATE type for its column type.