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 date_format creation option

Specify the format used for converting date values to strings.

Syntax
date_format=value
Allowed values

String

Default

YYYY-MM-DD (this corresponds to ISO date format specifications)

Remarks

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

The default date format YYYY-MM-DD conforms to ISO 8601. For example, "January 7, 2006" in this format is presented as "2006-01-07". You can specify a different format and order for year, month, and day.

The format is a string using the following symbols:

Symbol Description
YY Two digit year.
YYYY Four digit year.
MM Two digit month, or two digit minutes if following a colon (as in hh:mm).
MMM[m...] Character short form for month. As many characters as there are "m"s. An uppercase M causes the output to be made uppercase.
D Single digit day of week, (0 = Sunday, 6 = Saturday).
DD Two digit day of month. A leading zero is not required.
DDD[d...] Character short form for day of the week. An uppercase D causes the output to be made uppercase.
JJJ Julian day of the year, from 1 to 366.

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

Allowed values are constructed from the symbols listed in the table above. Each symbol is substituted with the appropriate data for the date that is being formatted.

  • Controlling output case

    For symbols that represent character data (such as MMM), you can control the case of the output as follows:

    • Type the symbol in uppercase to have the format appear in uppercase. For example, MMM produces JAN.

    • Type the symbol in lowercase to have the format appear in lowercase. For example, mmm produces jan.

    • Type the symbol in mixed case to have UltraLite choose the appropriate case for the language that is being used. For example, in English, typing Mmm produces May, while in French it produces mai.

  • Controlling zero-padding

    For symbols that represent numeric data, you can control zero-padding with the case of the symbols:

    • Type the symbol in same-case (such as MM or mm) to allow zero padding. For example, yyyy/mm/dd could produce 2002/01/01.

    • Type the symbol in mixed case (such as Mm) to suppress zero padding. For example, yyyy/Mm/Dd could produce 2002/1/1.

From SQL Central, you can set the date format in any wizard that creates a database. On the New database creation parameters page, click the Date Format option.

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

Example

The following table illustrates date_format settings, together with the output from a SELECT CURRENT DATE statement, executed on Thursday May 21, 2001.

date_format syntax used Result returned
YYYY/MM/DD/ddd 2001/05/21/thu
JJJ 141
mmm YYYY may 2001
MM-YYYY 05-2001