We have date "30-DEC-99" in oracle database but when our code reads that date is reading like "datetime.datetime(1899, 12, 30, 0, 0)", why the year 99 is reading like 1899 rather 1999? how do I fix this issue? please suggest.

I don't know why it reads 1899. Here is a possible patch

>>> import datetime as dt
>>> def patch_datetime(x):
...   delta = x - dt.datetime(x.year, x.month, x.day)
...   s = "{:0>2}-{:0>2}-{:0>2}".format(x.day, x.month, x.year % 100)
...   d = dt.datetime.strptime(s, '%d-%m-%y')
...   return d + delta
... 
>>> x = dt.datetime(1899, 12, 30, 0, 0)
>>> x = patch_datetime(x)
>>> x
datetime.datetime(1999, 12, 30, 0, 0)
>>> y = dt.datetime(year = 2014, month=2, day = 5)
>>> y = patch_datetime(y)
>>> y
datetime.datetime(2014, 2, 5, 0, 0)

Edit: bugfix to include date and time.

Note that there may be some more trouble if the database contains '29-FEB-00' because 2000 is a leap year, and not 1900.

Is this part of the Millennium bug?

commented: who knows ? +14
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.