ibtissem ibtissem - 2 years ago 112
Python Question

Not a valid month error

i have a problem with python developpement.
I try to insert records to my database table , but i have this error when i trying to insert using cx_Oracle for python : not a valid month.
And when i try to run this same query in sqldeveloper ,there is no problem
this my code :

cursor.execute("insert into mytable(tableid,tablename,timecreate)values('45125','test',to_timestamp(to_char(sysdate,'dd/mm/yy')))")

I don't know what is the difference?
Have you any idea?

Answer Source

Assuming you want just the mm/dd/yy (remove hours,mins,sec) from a sysdate and convert to a timestamp, try this instead of your to_timestamp call:


No need to convert to char and back.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download