how to get 2 digits after decimal point in tsql?

前端 未结 8 1059
梦如初夏
梦如初夏 2021-02-02 05:42

I am having problem to format digits in my select column.I used FORMAT but it doesn\'t work. Here is my column:

sum(cast(datediff(second, IEC.CREATE_DATE, IEC.ST         


        
8条回答
  •  南笙
    南笙 (楼主)
    2021-02-02 06:10

    Assume that you have dynamic currency precision

    • value => 1.002431

    • currency precision => 3

    • `result => 1.002

    CAST(Floor(your_float_value) AS VARCHAR) + '.' + REPLACE(STR(FLOOR((your_float_value FLOOR(your_float_value)) * power(10,cu_precision)), cu_precision), SPACE(1), '0')

提交回复
热议问题