Year 2000 compliance
Ambiguous date
conversion
example
Date to string conversions
Wrong century
values
300
If this option is not set, the default setting of 50 is assumed, thus adding 1900
to two digit year strings and placing them in the 20th century.
This NEAREST_CENTURY option was introduced in SQL Anywhere
Version 5.5. In version 5.5, the default setting was 0.
The following statement creates a table that can be used to illustrate the
conversion of ambiguous date information in Adaptive Server Anywhere.
CREATE TABLE T1 (C1 DATE);
The table T1 contains one column, C1, of the type DATE.
The following statement inserts a date value into the column C1. Adaptive
Server Anywhere automatically converts a string that contains an ambiguous
year value, one with two digits representing the year but nothing to indicate
the century.
INSERT INTO T1 VALUES('00-01-01');
By default, the NEAREST_CENTURY option is set to 50, thus Adaptive
Server Anywhere converts the string into the date 2000-01-01. The following
statement verifies the result of this insert.
SELECT * FROM T1;
Changing the NEAREST_CENTURY option using the following statement
alters the conversion process.
SET OPTION NEAREST_CENTURY = 0;
When NEAREST_CENTURY option is set to 0, executing the previous
insert using the same statement will create a different date value:
INSERT INTO T1 VALUES('00-01-01');
The above statement now results in the insertion of the date 1900-01-01. Use
the following statement to verify the results.
SELECT * FROM T1;
Adaptive Server Anywhere provides several functions for converting
Adaptive Server Anywhere date and time values into a wide variety of
strings and other expressions. It is possible in converting a date value into a
string to reduce the year portion into a two digit number representing the
year, thereby losing the century portion of the date.
Consider the following statement, which incorrectly converts a string
representing the date Jan 1, 2000 into a string representing the date Jan 1,
1900 even though no database error occurs.
Need help?
Do you have a question about the Adaptive Server Anywhere and is the answer not in the manual?
Questions and answers