Leap years
Ambiguous string to date conversions
For more information on the ODBC TIMESTAMP structure, see the
Microsoft Open Database Connectivity SDK, or "Sending dates and times to
the database" on page 277.
Used in the development of C programs, an embedded SQL
SQLDATETIME structure's year value is a 16-bit signed integer.
For more information on the SQLDATETIME data type, see "Embedded
SQL data types" on page 17 of the book ASA Programming Interfaces
Guide.
The year 2000 is also a leap year, with an additional day in the month of
February. Adaptive Server Anywhere uses a globally accepted algorithm for
determining which years are leap years. Using this algorithm, a year is
considered a leap year if it is divisible by four, unless the year is a century
date (such as the year 1900), in which case it is a leap year only if it is
divisible by 400.
Adaptive Server Anywhere handles all leap years correctly. For example:
The following SQL statement results in a return value of "Tuesday":
SELECT DAYNAME('2000-02-29');
Adaptive Server Anywhere accepts Feb 29, 2000 — a leap year — as a date,
and using this date determines the day of the week.
However, the following statement is rejected by Adaptive Server Anywhere:
SELECT DAYNAME('2001-02-29');
This statement results in an error (cannot convert '2001-02-29' to a date)
because Feb 29 does not exist in the year 2001.
Adaptive Server Anywhere automatically converts a string into a date when a
date value is expected, even if the year is represented in the string by only
two digits.
If the century portion of a year value is omitted, the method of conversion is
determined by the NEAREST_CENTURY database option.
The NEAREST_CENTURY database option is a numeric value that acts as a
break point between 19YY date values and 20YY date values.
Two-digit years less than the NEAREST_CENTURY value are converted to
20yy, while years greater than or equal to the value are converted to 19yy.
Chapter 7 SQL Data Types
299
Need help?
Do you have a question about the Adaptive Server Anywhere and is the answer not in the manual?
Questions and answers