How to remove the decimal point from a string

49 Views Asked by At

We have an extract from Oracle when looking up the iby_trxn_documents table

The Value (invoice amount) is a string.

Examples are below:

  1. 54380
  2. 19.80

I would like:

  1. 54380 Dollars and 0 Cents
  2. 19 Dollars and 80 Cents

We need to split this string so it is XX Dollars and XX Cents

How can I create logic to split this? I am using an RTF in MS Word.

Any help would be much appreciated!

I have tried:

<?xdoxslt: truncate(PaymentAmount/Value * 1)?>
<?xdofx:floor(format-number:PaymentAmount/Value;’99G999G999’?>
<?format-number:PaymentAmount/Value;’######’?>
<?truncate(format-number:PaymentAmount/Value;’999G999D99’)?>
<?round(format-number:PaymentAmount/Value;’999G999D99’)?>
<?format-number(round(100 * $number) div 100, '#.00')?>

The below working and is now not however as there aren't any '.' in the example above (54380), the query fails where there is no decimal so it doesn't actually work.

<?xdofx:substr(PaymentAmount/Value,1,Instr(PaymentAmount/Value,'.',-1)-1)?>
2

There are 2 best solutions below

0
y.arazim On

If you are using XSLT, you can do:

<xsl:value-of select="floor(Value)"/>
<xsl:text> Dollars and </xsl:text>
<xsl:value-of select="100 * Value mod 100"/>
<xsl:text> Cents</xsl:text>

Demo here.

0
Ranjith R On

Just try multiplying value by 1.00, this should add the decimal point back where they are missing. Its a standard trick used in eText templates.

<?xdofx:substr(PaymentAmount/Value * 1.00,1,Instr(PaymentAmount/Value,'.',-1)-1)?>