Casting Field Values using TO_NUMBER and TO_NCHAR

Fields in NetSuite store values in different data types, such as STRING, INTEGER, and FLOAT.

You may need to change a field to another data type before using it in a custom formula or running calculations. For example, if item price is an INTEGER and cost is a FLOAT, use this formula to get the difference:

          TO_NUMBER({item<pricing.unitprice}) - TO_NUMBER({cost}) 

        
Casting values using TO_NUMBER and TO_CHAR. Possible Profit column on the Item Dataset page.

Use the formulas in the table below if you need to change a field to a different data type:

Data Type

To cast to STRING

To cast to INTEGER

To cast to FLOAT

INTEGER

TO_CHAR({field_ID})

-

Automatic casting

FLOAT

TO_CHAR({field_ID})

CEIL({field_ID})

FLOOR({field_ID})

ROUND({field_ID})

TRUNC({field_ID})

-

BOOLEAN

Automatic casting, returns 'T' or 'F'

CASE field WHEN 'T' THEN 1 ELSE 0 END

CASE field WHEN 'T' THEN 1 ELSE 0 END

DATE

TO_CHAR({field_ID})

-

-

DATETIME

TO_CHAR({field_ID})

-

-

PERCENT

TO_CHAR({field_ID})

Returns values between 0 and 1

-

TO_NUMBER({field_ID})

DURATION

TO_CHAR({field_ID})

Returns FLOAT values, not in the hours:minutes format

-

TO_NUMBER({field_ID})

STRING

-

TO_NUMBER({field_ID})

Not preferred

TO_NUMBER({field_ID})

CURRENCY

TO_CHAR({field_ID})

Returns values without the currency symbol

-

TO_NUMBER({field_ID})

CURRENCY_HIGH_PRECISION

TO_CHAR({field_ID})

Returns values without the currency symbol

-

TO_NUMBER({field_ID})

Related Topics

General Notices