1

How do I make informix handle 4 digit years?

I have both windows and suse servers using informix

Thank you.

Mark Henderson
  • 68,823
  • 31
  • 180
  • 259
sergiogx
  • 335
  • 3
  • 15

1 Answers1

4

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.

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
  • 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 04 '10 at 05: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 05 '10 at 01:35
  • You'll probably need to dig into the SQL code. Here's some more information: https://www.ibm.com/developerworks/data/library/techarticle/dm-0510roy/ – Dennis Williamson Jan 05 '10 at 03: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 08 '10 at 23:43