4

I work in a large scale IT support environment. Twice now we have seen an invalid date of 02/31/2157 being inserted in an Oracle DATE column. So far I have not been able to reproduce this problem, but it appears to be happening occasionally when a user attempts to save '00/00/0000' into the column. I believe the value is originating from a PowerBuilder DataWindow update.

The application uses myriad libraries for all sorts of technologies, so this question may be a bit vague, but...

Has anyone seen the date 02/31/2157 in some established library that Oracle could be defaulting to when some other invalid date is entered? Perhaps an end-of-time concept analogous to the beginning-of-time date of 1/1/1970?

4
  • What's inserting the data? Is it like a Java program or Oracle Forms? It could be happening before the DBMS.
    – JOTN
    Jan 11, 2011 at 15:40
  • It's updating from a PowerBuilder DataWindow. Edited the OP to include that info.
    – dpatchery
    Jan 11, 2011 at 15:53
  • "beginning-of-time date of 1/1/1971" Nitpick: That would be 1/1/1970.
    – Powerlord
    Jan 11, 2011 at 16:00
  • 2
    Fixed. I blame today's date of 1/11/11 for inserting random 1's into all text 1 type today.
    – dpatchery
    Jan 11, 2011 at 16:06

3 Answers 3

4

From http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/datatype.htm#i1847"

Oracle uses its own internal format to store dates. Date data is stored in fixed-length fields of seven bytes each, corresponding to century, year, month, day, hour, minute, and second.

2157-256 = 1901, which seems suspiciously close to a possible epoch of 1/1/1900 (or 12/13/1901 - which is the rollover date for the Year 2038 Problem)

I'd guess that it is storing either 0x00 or 0xFF in the date bytes, then getting confused when it decodes it. (How does it deal with month 255?)

4
  • 1
    It can be useful to do a SELECT DUMP(date_col) ... to see the individual bytes. It is possible to store invalid dates into a date field (but not easy at the SQL level). When an invalid 7-byte date is returned to a client (such as TOAD or SQL*Plus) it is up to that client to display it, so the same invalid database value may get displayed different ways by different clients.
    – Gary Myers
    Jan 11, 2011 at 22:39
  • This sounds like a possibility, but the application restricts users from entering nonvalid dates. To be more specific, only a valid date/month combination between 01/01/0001 and 12/31/9999 can be entered. I tried entering several dates obscenely far into the future to try to run into the rollover problem you described, but I have still been unable to recreate the issue.
    – dpatchery
    Jan 12, 2011 at 14:27
  • To check for the bug I mentioned in my answer, try dates like 2/29/2011. These were not rejected and changed to a strange date. I don't have my notes anymore (really draconian IP agreement, I had to certify that I had nothing from that job when I left). Jan 12, 2011 at 18:06
  • I did try several invalid dates by working around the edit mask, including 02/29/<non-leap-year> and 02/31/2157 specifically. However, our application has a second layer of logic beyond the edit mask that enforces a valid date before saving. Thanks for the suggestion though!
    – dpatchery
    Jan 14, 2011 at 14:52
2

Turns out this was a powerbuilder issue. The field was created in the datawindow as required, but was programmatically changed to be non-required before saving. So a null value was being saved to a non-null database column, and powerbuilder inserted some dummy date instead of just throwing an error.

0

I remember getting a weird value when saving an invalid date. IIRC it was in PB 9 and we had to get an EBF for it. It was a problem with Date Editmasks and entering an invalid date that wasn't rejected. Sorry I don't have more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.