How To Conver SALES VALUE From 9999.99 To 9.999,99
Currently looking for an easy way to convert 99999.99 to 9.999,99 format: This is what I have currently: CREATE TEMP FUNCTION FORMAT_DE_VALUE(number FLOAT64) RETURNS STRING LANGUAG
Solution 1:
If you can't use regex, then you can try something like this that uses QoL Array methods.
The idea is to start in reverse and to have each item of your list as a string containing a maximum of three digits.
const [whole, dec] = 9999999.99
.toFixed(2)
.split(".");
const res = whole
.split("")
.reverse()
.reduce((acc,cur)=>{
if(acc[0].length === 3){
acc.unshift("");
}
acc[0] = cur + acc[0];
return acc;
}, [""])
.join(".")
.concat("," + dec)
console.log(res);
Post a Comment for "How To Conver SALES VALUE From 9999.99 To 9.999,99"