Can I format a float with a specific scientific notation format?

  • I have a table with floats and I want to format them in a view so that they are always displayed like 9.999e-03, always with 3 digits (and only 3 digits) to the right of the decimal.  Is there a function, or some other method to do this?

    Thank you,

    Bob

  • How about this:

    CREATE FUNCTION dbo.uSN3(@n FLOAT)

    RETURNS VARCHAR(12)

    AS

    BEGIN

     -- delete charpos 6,7,8,9 after converting to scientific notation

     RETURN Stuff(Convert(varchar(20), @n, 1), 6, 4, '')

    END

    Mike

     

  • Thank you.

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

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