Tabular IQ
Back to Function Index

STR()

Overview

STR() is a versatile function that can be used in two ways: to convert numbers to strings with optional precision, or to convert dates to strings in YYYYMMDD format. When used with numbers, it rounds the value to the specified precision (or zero decimal places if not specified). When used with dates, it returns an 8-character string representing the date in YYYYMMDD format.

Function Format

STR(number [, precision])
STR(date)

Return Value

STR() returns a character string

Examples


// Number conversion with default precision (0)
STR(10.5) = "11"

// Number conversion with specified precision
STR(1.23456789, 2) = "1.23"
STR(5.555555, 2) = "5.56"

// Date conversion
STR(DATE(2002, 12, 25)) = "20021225"
STR(DATE("11/05/2002")) = "20021105"

// Additional examples
STR(0) = "0"                    // Zero value
STR(-10.5) = "-11"             // Negative number
STR(DATE(null)) = "00000000"   // Null date

Notes

  • Important behaviors:
    • Number conversion:
      • Rounds to specified precision
      • Defaults to zero decimal places
      • Handles negative numbers
      • Preserves sign in output
    • Date conversion:
      • Returns YYYYMMDD format
      • Handles various date inputs
      • Returns "00000000" for null dates
      • 8-character fixed length
  • Common use cases include:
    • Number formatting
    • Date standardization
    • Data type conversion
    • Report generation
    • Data export
  • The function is useful for:
    • String representation of numbers
    • Date format standardization
    • Data type conversion
    • Output formatting

See Also