Skip to main content
Solved

How to use current system time in Python shutdown script?

  • March 11, 2016
  • 2 replies
  • 35 views

dbCursor.execute("""INSERT INTO FME_LOG(NAME, RUN_DATE) VALUES ('eee', datetime.datetime.now())""") is not working.

Best answer by david_r

Hi

If it's Oracle, you can use the built-in SYSDATE function to return the current timestamp without having to wrestle with Python datetime objects:

insert into fme_log(name, run_date) values ('eee', sysdate)

The equivalent to SYSDATE on MS SQL Server is "sysdatetime()" and on PostgreSQL it is "current_timestamp".

David

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

david_r
Celebrity
  • 8394 replies
  • Best Answer
  • March 11, 2016

Hi

If it's Oracle, you can use the built-in SYSDATE function to return the current timestamp without having to wrestle with Python datetime objects:

insert into fme_log(name, run_date) values ('eee', sysdate)

The equivalent to SYSDATE on MS SQL Server is "sysdatetime()" and on PostgreSQL it is "current_timestamp".

David


Forum|alt.badge.img+5
  • 52 replies
  • March 11, 2016

Hi

If it's Oracle, you can use the built-in SYSDATE function to return the current timestamp without having to wrestle with Python datetime objects:

insert into fme_log(name, run_date) values ('eee', sysdate)

The equivalent to SYSDATE on MS SQL Server is "sysdatetime()" and on PostgreSQL it is "current_timestamp".

David

Note that sysdate is the timestamp of the database server. This might be different from the timestamp of the client where you're running FME, which is the timestamp Python would give you. Sysdate is probably the one you want though.