Proper date abstraction in case statement

6 views
Skip to first unread message

jca...@gmail.com

unread,
Jun 15, 2021, 3:14:44 PM6/15/21
to sqlalchemy
Hi,
I have a case statement that should compare just the date for equality, however the code considers the time as well:

Model.dateCol == func.sysdate()

Another issue is this is a DATE field (therefore datetime) in an Oracle database in one environment and a DATE field (actual date) in an MSSQL database in another environment.

Would the correct way to achieve this comparison across both abstractions be:

cast(Model.dateCol, Date) == cast(func.sysdate(), Date)

Thanks,
jlc
Reply all
Reply to author
Forward
0 new messages