Conversion Functions in Expressions

Conversion functions convert expressions of one data type to another data type when data type conversions are not automatically performed by SQL Server.

This function uses a date, time, or numeric value and returns a formatted string representing that value according to a specified style string.

You can find these formats at the following Microsoft websites:

Conversion

The following information describes the functions available for building expressions.

FunctionSyntaxDescriptionExample
TruncTRUNC(number)Calculates the integral part of a number.TRUNC(3.67) = 3
ToDoubleToDouble(number)Converts a number or string to a double."4.5" = 4.5
ToDecimalToDecimal(number)Converts a number or string to a decimal."4.5" = 4.5
ToStringToString(object)Converts a value to a string. A null value becomes "NULL."ToString(4.5) = "4.5"
FormatFORMAT(number, style)Converts a number or date to a string formatted according to instructions contained in a format string expression. Returns a string value.FORMAT(4.5, "E") = "4.500000E+000"