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', Value String) The input value contains two STRING values. The first is called the Format String and has to be enclosed in single quotes. The Format String defines the formatting that is to be applied to the Value String. The formatting can be Boolean, Integer or Real, String, or Date/Time. For information on the various format string codes and characters, see Defining the Format of Displayed Values in the Geo SCADA Expert Guide to Core Configuration. The second part of the value is the Value String and this is an expression that defines the value to which the formatting is to be applied. The Value String should not be enclosed with single quotes. For more information on STRING values, see String. |
Returns |
STRING The output string is the Value String 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 digital 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.