change 2-digit year fields to 4-digit year fields
Posted in 2000
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
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 = ""; 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? 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...).
Leave the picture off altogether is the simplest way - if you have room on your form.. On Sat, 01 Jan 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 = ""; > >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? >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...).
Hi John-Thomas, I would suggest dropping the picture statement from the form definition, make sure there is enough room in the display field on the form or else you'll get a bunch of asterisks, and look at the way the program is displaying the field to the form. Just getting rid of the picture should do it. If not (some versions can be a little flakey), try making the line look as follows: A7 = formonly.fmt_initial_time type datetime year to minute not null; I also suggest removing any 'comment=""' references unless this is the standard that was used to clear window level comment lines. This is simply unnecessary code. I notice your original definition is listing the field as a 'type char', which is incorrect unless you are converting the date to a char variable, at which point you could utilize a USING statement to format the string during conversion. Good luck! Toodles, John Miceli In article <946715306.589282487@news.usxchange.net>, John-Thomas Richards <dawnex@usxchange.net> 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 = ""; > > 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? > 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...). > Sent via Deja.com http://www.deja.com/ Before you buy.
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 = ""; > > 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? > 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...). The database would always store a 4 digit date for the date, however if you have a 2 digit data entry for the date, then the database would automatically add 1900 to the 2 digits before storing it (in newer versions would add the current century) I do not believe DBCENTURY was implemented in your version of Informix products, so I skip talking about them. Though your form has been recompiled to take care of 4 digits, your application may be only sending a 2 digit number to that field, so you have to check the application. Finally the date formats may be effected by DBDATE environment so check that as well. -- Compliments of QueriX -------------------------------------------------------------------------------------------------- QueriX 4GL Compilers are Informix 4GL Compatible, and Connection to other RDBMS such as Oracle. Hydra 4GL Compiler Compile once, run everywhere Phoenix Windows GUI. Chimera Java GUI The only GUI you will ever need... Arachne Web Technology For more details visit: http://www.querix.com/ ---------------------------------------------------------------------------------------------------