Product SiteDocumentation Site

7.4.12. CENTER (or CENTRE)


>>-+-CENTER(-+--string,length--+------+--)---------------------><
   +-CENTRE(-+                 +-,pad-+

Returns a string of length length with string centered in it and with pad characters added as necessary to make up length. The length must be a positive whole number or zero. The default pad character is blank. If the string is longer than length, it is truncated at both ends to fit. If an odd number of characters is truncated or added, the right-hand end loses or gains one more character than the left-hand end.
Here are some examples:

Example 7.18. Builtin function CENTER

CENTER(abc,7)               ->    "  ABC  "
CENTER(abc,8,"-")           ->    "--ABC---"
CENTRE("The blue sky",8)    ->    "e blue s"
CENTRE("The blue sky",7)    ->    "e blue "

Note

To avoid errors because of the difference between British and American spellings, this function can be called either CENTRE or CENTER.