0

Using content builder to create emails, and pulling numbers in from a data extension.

Some are 9 digits and some are 10 digits.

Using 'format number' to show spaces between some of the digits so they show as either "### ### ###" or "### #### ###".

So I would always like to lead with a group of three digits.

I've used the following %%=formatnumber(@telNo,"### ### ###")=%% but in instances where there are 10 digits the extra digit always shows in that first group, so it returns "#### ### ###".

If I try %%=formatnumber(@telNo,"### #### ###")=%%, to add that extra digit to the middle group, when it's only 9 digits it returns "## #### ###".

Any potential solutions would be appreciated.

1 Answer 1

1

You can handle this by putting a check condition to find out if the tel number has 9 digits or 10 digits then have a proper format for it.

Try it yourself:

%%[
    set @telNo = 123456789
    /* set @telNo = 2987654321 */

    if Length(@telNo) == 9 then
        set @formatedNo = Format(@telNo, "### ### ###")
    else
        set @formatedNo = Format(@telNo, "### #### ###")
    endif
]%%
%%=v(@formatedNo)=%%

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .