Alok Agarwal Alok Agarwal - 1 year ago 108
Python Question

Insert Python datetime to Oracle column of type DATE

I am trying to store python datetime object to ORACLE column of type date.

so far, I have used,

rpt_time = time.strftime('%Y-%m-%d %H:%M:%S') or
rpt_time = str(

but all are giving ORA-01843: not a valid montn

I am really confused how to insert ORACLE date type python datetime object

Answer Source

As far as my search shows, ORACLE can be picky on dates so this might be what you need to do.

Firstly, check the format of date you have. For example, if you have something like, 2010/01/26:11:00:00AM, then you might want to do following on your cursor execute:

insert into x
values(99, to_date('2010/01/26:11:00:00AM', 'yyyy/mm/dd:hh:mi:ssam'));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download