Support Topics Documentation Slack YouTube Blog

How to convert double to currency format

Client SDK (REST / Android / Objective-C / Swift / JS )

Codeless

Application ID

5B75038B-CF13-4B09-AB38-4BCF5E7002BC

hello team backendless,
iam use dopsource
how to convert double to currency format? Thanks

Hello @xiaomieya

please provide example values, what you’ve got and what you want to get at the end

Regards, Vlad

hello @vladimir-upirov thanks for your respone.

I have a data table with double data types. like this.

when api call on dropsource the result is 2000.0 I want to get is 2,000 .


dropsource does not support currency format. DropSource technical support recommends doing this from the server side. can you help me?

Thanks @vladimir-upirov

When you put comma to separate digits in a number, it technically becomes a string. So while 2000 is an Double, "2,000" is already a string. To do this, you’d need to write logic either in codeless or on the Dropsource side to format the value that way.

hello @mark-piller

can you give me an example of how to convert double to string using codeless? thanks

Hi Xia,

Unfortunately, I cannot, this would be something our professional services team can do. This would be rather straight-forward - convert the number to a string and put a comma every 3 characters.

Mark

try to create a Codeless Custom Function:

and as result you will have the following:

0 => "$ 0"
2000 => "$ 2,000"
12330 => "$ 12,330"
89033 => "$ 89,033"
780 => "$ 780"
78 => "$ 78"
123456789 => "$ 123,456,789"

Regards, Vlad

2 Likes

oops, just noticed, there is a bug, the first char comes twice and there is no the last char in the result, let me fix

I’ve updated screen with logic and results

thanks @vladimir-upirov and @mark-piller its work.