Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » UltraLite - Database Management and Developer Guide » UltraLite database reference » UltraLite options

UltraLite nearest_century creation option

Specify the interpretation of two-digit years in string-to-date conversions.

Allowed values

Integer, between 0 and 100, inclusive




For Android devices, you can use Connection.setOption(OPTION_NEAREST_CENTURY, value) as an alternative to setting this creation option.

UltraLite 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. For a two-digit date, you need to set the appropriate rollover value. Two digit years less than the value are converted to 20yy, while years greater than or equal to the value are converted to 19yy.

Choosing an appropriate rollover value typically is determined by:

  • The use of two-digit dates

    Otherwise, nearest century conversion isn't applicable. Two-digit years less than the nearest_century value you set are converted to 20yy, while years greater than or equal to the value are converted to 19yy.

    Store four-digit dates to avoid issues with incorrect conversions.

  • Consolidated database compatibility

    For example, the historical SQL Anywhere behavior is to add 1900 to the year. Adaptive Server Enterprise behavior is to use the nearest century, so for any year where value yy is less than 50, the year is set to 20yy.

  • What the date represents: past event or future event

    Birth years are typically those that would require a lower rollover value since they occur in the past. So for any year where yy is less than 20, the year should be set to 20yy. However, if the date is used as an expiry date, then having a higher value would be a logical choice, since the date is occurring in the future.

You cannot change the nearest century of an existing database. Instead, you must create a new database.

From SQL Central, you can configure the nearest century setting in any wizard that creates a database. On the New database creation parameters page, click the Nearest Century option.

From a client application, set this option as one of the creation options for the CreateDatabase method on the DatabaseManager/ULDatabaseManager class.