Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

PI OLEDB Enterprise

FORMAT

  • Last UpdatedFeb 07, 2023
  • 3 minute read

Specify a format for numerical data types:

String FORMAT(x Float64, s String)
String FORMAT (x Float32, s String)
String FORMAT (x Int32, s String)
WString FORMAT (x Float64, s WString)
WString FORMAT (x Float32, s WString)
WString FORMAT (x Int32, s WString)

The format string (2nd parameter) may contain one of the following characters:

Character

Description

#

Displays a digit. Each instance of the character represents a position for one number. If no value exists in a position, PI OLEDB Enterprise displays a blank space.

For example, if you apply this format: #,###, but have a value of 45, you see nothing but the number 45. If you have a value of 12145, PI OLEDB Enterprise displays 12,145 – even though you defined only one placeholder to the left of the thousands separator.

0

Displays a digit. Each instance of the character represents a position for one number. If no value exists in a position, PI OLEDB Enterprise displays a zero (0).

Thousands and decimal separators

Indicates where you want to place the thousands and decimal separators. Use the separators defined in your Windows regional settings.

E+, E-

–or–

e+, e-

Displays values in scientific (exponential) notation. Use this option when the predefined scientific format does not provide enough room for your values. Use E+ or e+ to display values as positive exponents, and E- or e- to display negative exponents. You must use these placeholders with other characters.

For example, suppose you apply the format 0.000E+00 to a numeric field and then enter 612345. PI OLEDB Enterprise displays 6.123E05. PI OLEDB Enterprise first rounds the number of decimal places down to three (the number of zeroes to the right or left of the decimal separator). Next, PI OLEDB Enterprise calculates the exponent value from the number of digits that fall to the right (or left, depending on your language settings) of the decimal separator in the original value. In this case, the original value would have placed the five-digit value 02223 2013-07-03 cg Is this a typo? And what about the 105 at the end? to the right of the decimal point. For that reason, PI OLEDB Enterprise displays 6.123E+05, and the resulting value is the equivalent of 6.123 x 105.

Examples:

SELECT Format(5459.4, '##,##0.00') - Returns "5,459.40".

SELECT Format(334.9, '###0.00') - Returns "334.90".

SELECT Format(5, '0.00') - Returns "5.00".

SELECT Format(123.456, '##.##') - Returns "123.46".

Specify a format for DateTime data type

String FORMAT(x DateTime, s String)
WString FORMAT (x DateTime, s WString)

The format string (2nd parameter) can contain one of the following characters:

Character

Description

d or dd

Used to display the day of the month as one or two digits. For one digit, use a single placeholder. For two digits, use two placeholders.

M or MM

Used to display the month as either a one-digit or two-digit number.

MMM

Used to abbreviate the name of the month to three letters. For example, October appears as Oct.

MMMM

Used to spell out all month names.

yyyy

Used to display the 4 digits of the year.

yy

Used to display the last two digits of the year.

H or HH

Used to display the hour as one or two digits. 24-hour format.

h or hh

Used to display the hour as one or two digits. 12-hour format.

tt

Used to display 12-hour clock values with a trailing AM or PM.

m or mm

Used to display minutes as one or two digits.

s or ss

Used to display seconds as one or two digits.

f or ff or fff or ffff or fffff

Used to display subsecond fractions of up to 5 digits.

/ \ : - .

Characters, including spaces, allowed as delimiter.

Examples

SELECT Format(MyDateTime, 'h:m:s') - Returns "5:4:23".

SELECT Format(MyDateTime, 'hh:mm:ss tt') - Returns "05:04:23 PM".

SELECT Format(MyDateTime, 'MMM d yyyy') - Returns "Jan 27 2011".

SELECT Format(MyDateTime, 'HH:mm:ss') - Returns "17:04:23"

SELECT Format(MyDateTime, 'hh:mm:ss.fff') - Returns "05:04:23.000".

Related Links
TitleResults for “How to create a CRG?”Also Available in