Cast Method


This is an overview of what will happen when a column is cast from one data type to another.

Input

Output

 

Integer

Real

Currency

Date/DateTime/Time

String

Binary

LongInteger

SingleReal

TimeSpan

Boolean

Integer

Same value.

Value cast to real.

Value converted to decimal if it fits in the limit. Null otherwise.

Date* value is created using the integer value as ticks**.

Formatted using input formatter.

Null.

Value cast to LongInteger.

Value converted to SingleReal.

The integer value is interpreted as ticks and the ticks are converted  to a TimeSpan.

If the value is 1 then true. If the value is 0 then false.  Null otherwise.

Real

Integer part of real value if it fits in the limit. Null otherwise.

Same value.

Value converted to decimal if it fits in the limit. Null otherwise.

Date* value is created using the integer part of the value as ticks.

Formatted using input formatter.

Null.

Value cast to LongInteger if it fits in the limit. Null otherwise.

Value converted to SingleReal if it fits in the limit. Null otherwise.

The integer part is interpreted as ticks and the ticks are converted  to a TimeSpan.

If the value is 1 then true. If the value is 0 then false.  Null otherwise.

Currency

Integer part of decimal value if it fits in the limit. Null otherwise.

Decimal value rounded to Real if it fits, null otherwise.

Same value.

Date* value is created using the integer part of the value as ticks.

Formatted using input formatter.

Null.

Integer part of decimal value if it fits in the limit. Null otherwise.

Decimal value rounded to SingleReal if it fits, null otherwise.

The integer part is interpreted as ticks and the ticks are converted  to a TimeSpan.

If the value is 1 then true. If the value is 0 then false.  Null otherwise.

Date/DateTime/Time

Number of ticks converted to integer if it fits in the limit. Null otherwise.

Number of ticks converted to real.

Number of ticks converted to decimal if it fits in the limit. Null otherwise.

Same value.

Formatted using input formatter.

Null.

Number of ticks converted to LongInteger if it fits in the limit. Null otherwise.

Number of ticks converted to SingleReal if it fits in the limit. Null otherwise.

Takes ticks and converts them to a TimeSpan.

If ticks ==0, then false. True otherwise.

String

Try to parse using output formatter. Null if it failed to parse.

Try to parse using output formatter. Null if it failed to parse.

Try to parse using output formatter. Null if it failed to parse.

Try to parse using output formatter. Null if it failed to parse.

Same value.

Null.

Try to parse using output formatter. Null if it failed to parse.

Try to parse using output formatter. Null if it failed to parse.

Try to parse using output formatter. Null if it failed to parse.

Try to parse using output formatter. Null if it failed to parse.

Binary

Null.

Null.

 Null.

Null.

Null.

Same value.

Null.

Null.

Null.

Null.

LongInteger

Value converted to integer if it fits in the limit. Null otherwise.

Value cast to real.

Value converted to decimal if it fits in the limit. Null otherwise.

Date* value is created using the integer value as ticks**.

Formatted using input formatter.

Null.

Same value.

Value converted to SingleReal.

The integer value is interpreted as ticks and the ticks are converted  to a TimeSpan.

If the value is 1 then true. If the value is 0 then false.  Null otherwise.

SingleReal

Integer part of singlereal value if it fits in the limit. Null otherwise.

Value cast to real.

Value converted to decimal if it fits in the limit. Null otherwise.

Date* value is created using the integer part of the value as ticks.

Formatted using input formatter.

Null.

Value cast to LongInteger if it fits in the limit. Null otherwise.

Same value.

The integer value is interpreted as ticks and the ticks are converted  to a TimeSpan.

If the value is 1 then true. If the value is 0 then false.  Null otherwise.

TimeSpan

Number of ticks converted to integer if it fits in the limit. Null otherwise.

Number of ticks converted to real if it fits in the limit. Null otherwise

Value converted to decimal if it fits in the limit. Null otherwise.

Takes ticks and converts them to date value.

Formatted using input formatter.

Null.

Takes ticks and converts them to LongInteger value.

Takes ticks and converts them to SingleReal value.

Same value.

If the value is 1 then true. If the value is 0 then false.  Null otherwise.

Boolean

1 if true.

0 if false.

1 if true.

0 if false.

1 if true.

0 if false.

Converts to date value using the ticks 0 and 1.

Formatted using input formatter.

Null.

1 if true.

0 if false.

1 if true.

0 if false.

Converts to TimeSpan ticks using the ticks 0 and 1.

Same value.

* Date, DateTime or Time.

** Ticks are counted with the unit 100 nanoseconds, starting from the date 01-01-01 (January first, year one).

See also:

Conversion Functions