Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. mysql decimal fromat like ##.##

mysql decimal fromat like ##.##

Scheduled Pinned Locked Moved Database
csharpmysqlhelp
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gilbert Consellado
    wrote on last edited by
    #1

    I have decimal(10,2) table column, is there way to format it like if you have 10.02 it will display 10.02 then if you 10.50 it will display 10.5. It look like that format of .ToString("##.##") in c#. BTW this is on MySQL. I just want to omit the last zero of the decimal. I will appreciate for any help will come.

    Richard Andrew x64R S 2 Replies Last reply
    0
    • G Gilbert Consellado

      I have decimal(10,2) table column, is there way to format it like if you have 10.02 it will display 10.02 then if you 10.50 it will display 10.5. It look like that format of .ToString("##.##") in c#. BTW this is on MySQL. I just want to omit the last zero of the decimal. I will appreciate for any help will come.

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      Where will the number display, in a report, in a browser, in a Windows Form?

      The difficult we do right away... ...the impossible takes slightly longer.

      G 1 Reply Last reply
      0
      • G Gilbert Consellado

        I have decimal(10,2) table column, is there way to format it like if you have 10.02 it will display 10.02 then if you 10.50 it will display 10.5. It look like that format of .ToString("##.##") in c#. BTW this is on MySQL. I just want to omit the last zero of the decimal. I will appreciate for any help will come.

        S Offline
        S Offline
        Shweta N Mishra
        wrote on last edited by
        #3

        If you convert it to float and then round in SQL it would work as you need. check this

        declare @no float=10.20
        select Round(@no,2)

        i have executed it in sql server, so check if that works in My SQL or not

        Mark the answer as accepted if that worked for you :). And for down-voters please specify the reason to improve the solution :).

        G 1 Reply Last reply
        0
        • S Shweta N Mishra

          If you convert it to float and then round in SQL it would work as you need. check this

          declare @no float=10.20
          select Round(@no,2)

          i have executed it in sql server, so check if that works in My SQL or not

          Mark the answer as accepted if that worked for you :). And for down-voters please specify the reason to improve the solution :).

          G Offline
          G Offline
          Gilbert Consellado
          wrote on last edited by
          #4

          Thank you for your response but, it doesn't seems will work on MySql

          S 1 Reply Last reply
          0
          • Richard Andrew x64R Richard Andrew x64

            Where will the number display, in a report, in a browser, in a Windows Form?

            The difficult we do right away... ...the impossible takes slightly longer.

            G Offline
            G Offline
            Gilbert Consellado
            wrote on last edited by
            #5

            Actually it will be used in windows forms.

            1 Reply Last reply
            0
            • G Gilbert Consellado

              Thank you for your response but, it doesn't seems will work on MySql

              S Offline
              S Offline
              Shweta N Mishra
              wrote on last edited by
              #6

              did you tried it

              Mark the answer as accepted if that worked for you :). And for down-voters please specify the reason to improve the solution :).

              G 1 Reply Last reply
              0
              • S Shweta N Mishra

                did you tried it

                Mark the answer as accepted if that worked for you :). And for down-voters please specify the reason to improve the solution :).

                G Offline
                G Offline
                Gilbert Consellado
                wrote on last edited by
                #7

                Yes I did, but there is no way I can cast decimal to float. I did a work around but it is ugly, it could cause a performance issue, so I am still looking for a better solution.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups