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.
STR(number [, precision])
STR(date)
STR() returns a character string
// 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