Chapter 7 SQL Data Types
301
SELECT DATEFORMAT (
DATEFORMAT(’2000-01-01’, ’Mmm dd/yy’ ),
’yyyy-Mmm-dd’ )
AS Wrong_year;
Although the unambiguous date string 2000-01-01 is automatically and
correctly converted by Adaptive Server Anywhere into a date value, the
’Mmm dd/yy’ formatting of the inner, or nested, DATEFORMAT function
drops the century portion of the date when it is converted back to a string and
passed to the outer DATEFORMAT function.
Because the database option NEAREST_CENTURY in this case is set to 0,
the outer DATEFORMAT function converts the string representing a date
with a two-digit year value into a year in the 20th century.
$ For more information on date and time functions, see "Date and time
functions" on page 304.