Common datetime call

11 views
Skip to first unread message

jca...@gmail.com

unread,
Jun 17, 2021, 7:21:14 PM6/17/21
to sqlalchemy
Hi,
Does a means exist to generically call a local datetime func such that it renders as SYSDATE in Oracle and GETDATE() in SQL Server?

Thanks,
jlc

Simon King

unread,
Jun 18, 2021, 5:45:20 AM6/18/21
to sqlal...@googlegroups.com
Do you need those functions explicitly? I think both databases support
the CURRENT_TIMESTAMP function (which you'd access as
sqlalchemy.func.current_timestamp()).

If you really do want to use different functions based on the
database, the compiler extension is what you want:

https://docs.sqlalchemy.org/en/14/core/compiler.html#utc-timestamp-function

Hope that helps,

Simon

Joseph L. Casale

unread,
Jun 18, 2021, 6:25:12 AM6/18/21
to sqlal...@googlegroups.com
Hi Simon,
I originally was relying on a utc datetime and was surprised to see that was
inconsistent with the rest of the application. As surprising as it, I do need a
local time and your example is perfect.

Thank you very much!
jlc
Reply all
Reply to author
Forward
0 new messages