Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7618259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:21:29+00:00 2026-05-31T03:21:29+00:00

In my database, I store money values without any points or commas. So I

  • 0

In my database, I store money values without any points or commas.
So I need a Javascript function that converts it into money string.

Example: Convert 500 (five dollars) into 5.00 , 100 into 1.00, 550 into 5.50 etc

Can anybody post a function like that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:21:31+00:00Added an answer on May 31, 2026 at 3:21 am

    You can use something like:

    function toAmount(amount){
      amount = Number(amount);
      if (isNaN(amount)){
        throw 'invalid: can\'t convert input';
      }
      return (amount/100).toFixed(2);
    }
    //usage
    toAmount(500);    //=> 5.00
    toAmount(520873); //=> 5208.73
    toAmount('500');  //=> 5.00
    

    Or use that function as an extension to Number

    Number.prototype.toAmount = function toAmount(amount){
      return (this/100).toFixed(2);
    };
    //usage:
    (500).toAmount();    //= 5.00
    (520873).toAmount(); //=> 5208.73
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a decimal column to store money values on a database, and today
I need to store a couple of money related fields in the database but
I need to store database passwords in a config file. For obvious reasons, I
I am trying to store some pictures into my SQL Server database from a
Possible Duplicates: Inserting images into a database Store images in database or on file
I created an MVC web application that was using a MSSQL database store for
I have a core data model, using the database store, that contains entities with
This database will store a list of children. But the problem is, they will
My MySQL database can store the euro symbol just fine (as I have tested
I'd like to use a database to store i18n key/value pairs so we can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.