I have a model and one of its attributes is a column 
called last_updated_timestamp . It is a date column set 
to datetime.datetime.now() . That's all good.

I'm trying to query for some roles based on a date range. So I do:

results = 
WorkForceTable.query.filter(WorkForceTable.last_updated_timestamp.between(form.from_dt.data,
 
form.to_dt.data)).all()

where form.to_dt.data and form.from_dt.data are datetime.date values.

The table currently has rows all with last_updated_timestamp set to today's 
date. Yet, when I run the above query and I set both dates to today's date, 
I get nothing returned. When I set the 'from date' to today and 'to date' 
to tomorrow's date, I get all the results I need. Why is that? Am I 
misunderstanding something? Looks like it includes results for the 'from 
date' but not results for the 'to date'.

I was under the impression that using 'between' will give me the results 
inclusive of the endpoints. I even switched and tried the >= and <= but the 
result is the same. What could be wrong? Basically, when I pass a starting 
date and an ending date to a between construct, why do I not get the right 
results? Especially, I have both to and from set to the same date. All my 
rows are date stamped today's date too.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to