On 02/29/2016 06:01 PM, Nana Okyere wrote:
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.
Oracle's DATE type includes a time portion. So if you have a date "2016-01-15 15:45:00", it will only be located in a BETWEEN if you specify a timestamp greater than or equal to that as the end range. That's why setting the end range to '2016-01-16 00:00:00", e.g. tomorrows date, works, and sending "2016-01-15 00:00:00" does not.
That's at least what it sounds like is happening as this is very common. Turn on echo=True on your engine to see the values specifically.
-- 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 <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com>. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
-- 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.