SQL/MP Reference Manual

HP NonStop SQL/MP Reference Manual523352-013
C-5
Valid Considerations—CAST
When casting data to a CHAR or VARCHAR data type, the resulting data value is
left justified. Otherwise, the resulting data value is right justified. Further, when you
are casting to a CHAR or VARCHAR data type, you must specify the length of the
target value.
Valid Considerations—CAST
You can convert:
An exact or approximate numeric value to any other numeric data type.
An exact or approximate numeric value to any character string data type.
An exact numeric value to either a single-field year-month or day-time interval,
such as INTERVAL '30' DAY.
A character string to any other data type, with this restriction:
The contents of the character string to be converted must be consistent in meaning
with the data type of the result. For example, if you are converting to DATE, the
contents of the character string must be 10 characters, consisting of the year, the
hyphen, the month, another hyphen, and the day.
A date value to a character string or to a TIMESTAMP (NonStop SQL/MP fills in
the time part with 00:00:00.00).
A time value to a character string or to a TIMESTAMP (NonStop SQL/MP fills in the
date part with the current date).
A timestamp value to a character string, a DATE, a TIME, or another DATETIME
with different fractional seconds precision.
A year-month interval value to a character string, an exact numeric, or to another
year-month INTERVAL with a different start field precision.
A day-time interval value to a character string, an exact numeric, or to another
day-time INTERVAL with a different start field precision.
You cannot perform the following conversions between the datatypes:
NUMERIC to DATETIME, INTERVAL to DATETIME
DATETIME to NUMERIC, DATETIME to INTERVAL
NUMERIC to INTERVAL, INTERVAL to NUMERIC
INTERVAL YEAR TO MONTH to INTERVAL DAY TO FRACTION
INTERVAL DAY TO FRACTION to INTERVAL YEAR TO MONTH
INTERVAL to FLOAT, FLOAT to INTERVAL
INTERVAL to character (other than fixed length char)
Character (other than fixed length char) to INTERVAL