Select Query Difference Doubt

  • Hi ,

    I am using following Query out. But I dont know what is difference .Please explain me.

    select convert(money,convert(float,64.98695))  
    Output : 64.9869
    select convert(money,convert(float,63.98695))
    Output : 63.987

    What is a difference?

  • vs.satheesh - Tuesday, August 8, 2017 8:06 AM

    Hi ,

    I am using following Query out. But I dont know what is difference .Please explain me.

    select convert(money,convert(float,64.98695))  
    Output : 64.9869
    select convert(money,convert(float,63.98695))
    Output : 63.987

    What is a difference?

    From BOL:

    The money and smallmoney data types are accurate to a ten-thousandth of the monetary units that they represent.

    Your examples go down to hundred-thousandth accuracy.
    Rewriting the queries as follows

    select convert(money,convert(float,64.9869))
    --Output : 64.9869
    select convert(money,convert(float,63.9869))
    --Output : 63.9869

    Removes the inaccuracy.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply