FORMATVAL
The FORMATVAL function applies formatting to a value and returns a string value.
Function Name |
FORMATVAL |
Description |
Applies formatting to a value and returns the result as a string value. |
Arguments |
FORMATVAL('Format String', Format Value) The first argument is a string that defines the formatting that is to be applied to the Format Value. You can use this string to apply Boolean, Integer or Real, String, or Date/Time formatting (as appropriate for the type of value that you want to format). For information about the various Format String codes and characters, see Defining the Format of Displayed Values in the Geo SCADA Expert Guide to Core Configuration. If this string is a string literal, enclose it within single quotation marks. The second argument is an expression that defines the value to which the formatting is to be applied. This argument can comprise any supported data type. If this argument is a string literal, enclose it within single quotation marks. For more information about STRING values, see String. |
Returns |
STRING The output string is the Format Value after the formatting defined by the Format String has been applied. |
Examples:
Boolean:
FORMATVAL('t', 0)
The output is 'f' because 0 is false and the format is t/f. The Format String for the t/f format is 't'.
Numeric:
FORMATVAL('#.00', 123.456)
The output is 123.46 as the '#.00' format string sets the result to have 2 decimal places.
String:
FORMATVAL('>', 'AbRaCaDaBrA')
The output is ABRACADABRA as the '>' format string sets the entire result to upper case.
Date:
FORMATVAL('dd MMM yyyy',".Analog Point.CurrentTime")
The output is 31 Nov 2005. This expression returns the CurrentTime value of the 'Analog Point' database item in the required format (dd MMM yyyy). In this case, the CurrentTime value is '31/Nov/2005 12:52:18.625' and this is formatted to 2 numbers for the day, 3 letters for the month, and 4 numbers for the year only.