Does there exist for SQLite something similar as the TRUNCATE function from MySQL?
SELECT TRUNCATE(1.999,1); # 1.9
There is no built-in function that would do this directly. However, you can treat the number as a string, search for the decimal separator, and count characters from that:
SELECT substr(1.999, 1, instr(1.999, '.') + 1);
(This does not work for integers.)
You can do this numerically by converting to an int and back:
select cast((val * 10) as int) / 10.0
You can do this using round()
and subtraction:
select round(val - 0.1/2, 1)
Or, as another answer suggests, you can convert to a string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With