Previous Topic: CHAR Function--Convert an ASCII Value

Next Topic: COMMONDN Function--Find a Common Root

CENTER Function--Pad a Source String

The CENTER function pads both ends of a source string with a specified character until the resulting string is a specified length. If the padding is uneven, the function adds an extra character to the end of the string.

Syntax

The CENTER function has the following format:

CENTER(source, length[, padding])

Parameters

The CENTER function accepts the following parameters:

source (string or number)

Specifies the source string. The function automatically converts a number to a string.

length (number)

Specifies the length of the resulting string.

padding (string)

(Optional) Specifies the character that the function uses to pad the source string.

Return Value

The CENTER function returns a string.

Example

Return_value=CENTER('Robin', 9, '*')
Return_value='**Robin**'

Return_value=CENTER('Robin', 7, 'ooo')
Return_value='oRobino'

Return_value=CENTER('Robin', 7, '')
Return_value='Robin'

Return_value=CENTER('Robin', 11)
Return_value='   Robin'

Return_value=CENTER(123, 9)
Return_value='000123000'

More information:

LPAD Function--Pad a Source String on the Left

RPAD Function--Pad a String on the Right


Copyright © 2010 CA. All rights reserved. Email CA about this topic