Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How do I make informix handle 4 digit years?

I have both windows and suse servers using informix

Thank you.

share|improve this question
    
See my edit for more information. –  Dennis Williamson Jan 4 '10 at 8:07
add comment

1 Answer

up vote 4 down vote accepted

The values of DBDATE and DBCENTURY affect the number of digits in the year.

DBDATE defaults to MDY4/ (for the US English locale) which includes a four-digit year.

DBCENTURY controls how to interpret data that includes two-digit years.

See also GL_DATE and DBTIME.

Edit:

A DATE type stores an integer number of days since December 31, 1899 in four bytes which will handle dates for 2^31 days which is over 5.8 million years into the future.

A DATETIME type can store anything from milliseconds to years in a size that's appropriate to the precision.

See Chronological Data Types which says, in part:

To customize this DATETIME format, choose your locale appropriately or set the GL_DATETIME or DBTIME environment variable. For more information about these environment variables, see the IBM Informix: GLS User's Guide.

share|improve this answer
1  
am i right in understanding this mean that informix stores the date properly, but as default only displays the year as two characters? –  BuildTheRobots Jan 4 '10 at 5:49
    
I tried setting the global variable GL_DATE = %d/%m/5Y, and it works in command promp, but it shows 2 digits on my web services and server studio :( –  sergiogx Jan 5 '10 at 1:35
    
You'll probably need to dig into the SQL code. Here's some more information: ibm.com/developerworks/data/library/techarticle/dm-0510roy –  Dennis Williamson Jan 5 '10 at 3:15
1  
@MidnighToker: yes - Informix stores the date unambiguously, but you can control the way it displays it. I always run with DBDATE='Y4MD-' set so my DATE values appear as '2010-04-08' etc by default. As Dennis said, there are lots of ways of refining this. Note that the DATETIME variants store the values accurately too - but using a different storage notation. Both DATE and DATETIME values are restricted to the range 0001-01-01 .. 9999-12-31; I plan to start work on the Y10K problem on 5000-01-02 (assuming I'm still paying attention to anything on that date). –  Jonathan Leffler Apr 8 '10 at 23:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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