Survey Tabulation > Advanced expressions > Locale handling in the UNICOM Intelligence Data Model
 
Locale handling in the UNICOM Intelligence Data Model
Different formatting conventions are used in different countries for dates and times and for the decimal and thousands separators used in numeric data. The UNICOM Intelligence Data Model therefore uses the locale setting to parse date, time, and numeric data. When inputting data it is important that you use the date and time formats, decimal symbols, and so on, appropriate to the locale you are using. (You select the locale using Regional Options in the Windows Control Panel.)
The Case Data Model handles locale settings using two connection properties:
MR Init Input Locale
This specifies the locale used when case data is inserted or updated. The input locale is used when converting text representations of numbers and dates to numeric and date types.
MR Init Output Locale
This specifies the locale used to output data and present errors. The output locale is used when converting numbers and dates to text and when presenting error messages.
Typically, both the input and output locale are the same. A distinction is made between the two to handle situations where, for example, an interview is presented in one language and answered in another.
If one of these connection properties is not specified, the locale ID is selected as follows:
language neutral
the thread’s locale value
the user’s default locale value
the system default locale value
US English.
Whenever a locale ID is not specified, the user's regional settings will override the locale ID selected by the system. Conversely, if a locale ID is specified, the default regional settings for that locale ID are used and the user's regional settings have no effect.
The UNICOM Intelligence Data Model stores the data in US English format. However, the locale handling means that this is normally invisible to the user.
Locale handling of numeric and date literals
A literal is a string of characters that represents a value. Literals are often used in expressions when you want to compare values. For example, the following expression uses a literal to select respondents whose income is above a specified value:
Income > 10000.00
The parsing of literals is always based on US English and is not dependent on the locale. This applies to both the UNICOM Intelligence Data Model and mrScriptBasic. This means that you must always specify date, time, and numeric literals in US English format. For example, the following expressions will give the desired results regardless of your locale:
DataCollection.FinishTime > "26 July 2002"
And Income >= "20000.00"
DataCollection.FinishTime > "26 July 2002"
And Income >= 20000.00
The following expression uses Danish date and number formatting and will always give incorrect results even when your locale is set to Danish:
DataCollection.FinishTime > "26 juli 2002"
And Income >= "20000,00"
The following expression also uses Danish date and number formatting and will give a syntax error. For example, in an SQL query the comma (,) in the numeric literal is interpreted as a column delimiter:
DataCollection.FinishTime > "26 juli 2002"
And Income >= 20000,00
However, the parameters to the functions in the function library (see UNICOM Intelligence Function Library) are parsed using the locale. This means that you can use the conversion functions to convert locale-specific date, time, and numeric values. For example, the following expression will give the desired results when you are working in a Danish locale:
DataCollection.FinishTime > CDate("26 juli 2002")
And Income >= CDouble("20000,00")
See also
Advanced expressions