Storing and rendering of Euro curreny values correctly

Storing and rendering of Euro curreny values correctly

burgard01burgard01 Posts: 5Questions: 2Answers: 0

Hi,

i want to store Euro currency values correctly in MySQL-DB and render the Euro value correct in DataTable(Editor). My two questions:

  1. How i store the curreny value in DB -> int or decimal?
  2. How i render correct with 2 numbers after comma (e.g. 6,50 € | 6.000,50 €)

Best regards
Thomas

Answers

  • takaesttakaest Posts: 5Questions: 2Answers: 0

    Hallo Thomas
    1. There are many solutions. I always use Decimal(19,4) (it is the most simple and best for scaling and dont loosing money).
    2. You could write your own function or use Number.prototype.toFixed e.g.
    Best regards

  • colincolin Posts: 15,115Questions: 1Answers: 2,583

    hi @burgard01 ,

    This example here may help, it's showing how to show different currency formats, note the line:

                { data: "salary", render: $.fn.dataTable.render.number( '.', ',', 0, '$' ) }
    
    

    Cheers,

    Colin

  • burgard01burgard01 Posts: 5Questions: 2Answers: 0

    Hi,

    thank you for the solution proposals. Now i understand and i have implemented the rendering function successfully!

    Best regards
    Thomas

This discussion has been closed.