The GL_DATE environment variable specifies the end-user formats of values in DATE columns. This variable is supported in Informix database servers 7.2x, 8.x, 9.x, and 10.x. A GL_DATE format string can contain the following characters:
Date formatting directives are defined in the following table.
A single digit is preceded by a zero (0).
A single digit is preceded by a space.
It is the Informix-specific formatting directive for %y.
It is the Informix-specific formatting directive for %Y.
The 0 represents the locale equivalent of Sunday.
For example, using %4m to display a month as a decimal number with a maximum field width of 4 is not supported.
The GL_DATE conversion modifier O, which indicates use of alternative digits for alternative date formats, is not supported.
White space or other nonalphanumeric characters must appear between any two formatting directives. If a GL_DATE variable format does not correspond to any of the valid formatting directives, errors can result when the database server attempts to format the date.
For example, for a U.S. English locale, you can format an internal DATE value for 09/29/1998 using the following format:
* Sep 29, 1998 this day is:(Tuesday), a fine day *
To create this format, set the GL_DATE environment variable to this value:
* %b %d, %Y this day is:(%A), a fine day *
To insert this date value into a database table that has a date column, you can perform the following types of inserts:
Enter the date value exactly as expected by the GL_DATE setting.
Enter the date value in the JDBC escape format yyyy-mm-dd; the value is converted to the GL_DATE format automatically.
The following example shows both types of inserts:
To retrieve the formatted GL_DATE DATE value from the database, call the getString() method of the ResultSet class.
To enter strings that represent dates into database table columns of char, varchar, or lvarchar type, you can also build date objects that represent the date string value. The date string value must be in GL_DATE format.
The following example shows both ways of selecting DATE values:
PreparedStatement pstmt = conn.prepareStatement("Select * from tablename " + "where col2 like ?;"); pstmt.setString(1, "%Tue%"); ResultSet r = pstmt.executeQuery(); while(r.next()) { String s = r.getString(1); java.sql.Date d = r.getDate(2); System.out.println("Select: column col1 (GL_DATE format) = <" + s + ">"); System.out.println("Select: column col2 (JDBC Escape format) = <" + d + ">"); } r.close(); pstmt.close();Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]