SQLite format number with 2 decimal places always

后端 未结 4 1192
日久生厌
日久生厌 2020-12-08 02:38

I have some tables in a SQLite database that contains FLOAT column type, now i want to retrieve the value with a Query and format the float field always with 2 decimal place

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-08 03:29

    You could try Select Str(12345.6789, 12, 3)

    displays: ' 12345.679'

    ( 3 spaces, 5 digits 12345, a decimal point, and three decimal digits (679). - it rounds if it has to truncate, (unless the integer part is too large for the total size, in which case asterisks are displayed instead.)

    for a Total of 12 characters, with 3 to the right of decimal point.

提交回复
热议问题