-3

I use CI to get some data in INT. And tried to change its format by using number_format. But it ends up as a string and can't be calculated.

I'd like the format to be something like "Rp 1.000.000".

So any solutions?

I rather new in scripting so some sample code or some detailed tutorial will be help

Eternity Neet
  • 179
  • 4
  • 17
  • Do you mean that you want to change it to be a number that you can do calculations with but has 'decimal places' so it will work out correctly? i.e. maybe interesting? [Decimal type in php](http://stackoverflow.com/questions/3244094/decimal-type-in-php) – Ryan Vincent Jun 07 '16 at 14:03

2 Answers2

0

Numbers don't have formats. You format a number as a string when you want to display it, not while you still need to compute with it.

Joni
  • 108,737
  • 14
  • 143
  • 193
0

Try something like the following:

CREATE TABLE #T(ID INT,CURRENCY INT)
INSERT INTO #T(ID,CURRENCY)
SELECT 1,1000
UNION 
SELECT 2,10000
UNION 
SELECT 3,30000
UNION 
SELECT 4,40000
UNION 
SELECT 5,50000


SELECT Id,
        CONCAT('Rp ',CAST(currency As decimal(10,3))) Currency 
FROM #T
Ahmad Baktash Hayeri
  • 5,802
  • 4
  • 30
  • 43
Srini
  • 1
  • 3