Re: change 2-digit year fields to 4-digit year fields
Posted in 2000
John-Thomas Richards wrote: > I inherited a system running Online 5.01 UCx w/ 4GL UC4. My department (sadly) > is currently in the process of switching to an AS/400 system. We are down to > the last program / form on the Informix database, which also happens to be the > most important. The primary underlying table has two date fields, intial_time > and resolved_time, both of which are datetime(year to minute). The form, > however, only displays two-digit years, though the table stores four-digit > years (eg, 1992-10-02 12:43). These dates are not data-entry fields; they are > inserted by the program based on other criteria ("Is the equipment up and > running? y/n). I assumed (incorrectly) that since the system inserted the > date and stores it as four-digit years, it would store the correct year (the > OS, SCO, is Y2K-OK). I changed the form and recompiled it to show four-digit > years: > > ATTRIBUTES > A7 = formonly.fmt_initial_time type char, noentry, > picture = "##/##/#### ##:##", comments = ""; > As Mehdi commented, this is likely to be affected by DBDATE being set with Y2 rather than Y4. You have a multitude of problems here. One is that you are using a TYPE CHAR field to enter DATETIME data. That implies one of two possibilities: * You are using a CHAR field to store the data. If so, then the date validation work is all done by your code, and it is largely up to you to ensure that the conversions are done correctly. Brutal, but honest. * You are in fact storing the data in a DATETIME YEAR TO MINUTE field, but you are displaying the date portion in a non-standard format. If so, then you still have conversion work done by your program, both on input and on output. And this code is not handling 2-digit vs 4-digit years correctly. So, to give you much more help, we are going to need to see how values are formatted for display to the formonly.fmt field, and how values are converted after data entry from those fields, and you are going to need to confirm that the people who run into problems have DBDATE=mdy2/ or DBDATE=dmy2/ or something similar set in their environment. > The form still displays two-digit years. (Please bear in mind that I am not an > Informix developer. I "inherited" this system because I was the only other > person in my company who knew how to use UNIX.) Am I correct in assuming that > if the form will display four-digit years, the DB will store the correct year? In general, yes. But it does depend on you using either DATE or DATETIME columns. If you use CHAR columns to store the date values, then all bets are off. > If so, how do I make it show them? (Please, if you are going to simply tell > me to RTFM, tell me which FM!) Though I am not an Informix developer, I am > willing to try many things (certainly not all things or even most things, just > many things...). Maybe the simplest test is to explicitly set DBDATE=dmy4/ in the environment (or mdy4/) and see whether the displays are OK. If so, then you will probably be OK if you force that in the environment (and forcing the environment from within the I4GL program is itself a major exercise), most simply by using a shell script to set the environment before running the program. You need to scrutinize your schema to determine whether the data is stored in CHAR fields or in DATE or DATETIME fields. Then get back to us if you've still got problems. -- Yours, Jonathan Leffler (jonathan.leffler@informix.com) #include Guardian of DBD::Informix v0.62 -- http://www.perl.com/CPAN "I don't suffer from insanity; I enjoy every minute of it!"