I have a text field with JSON structure in my Postgres v10.8 DB. I need to grab a value inside the config and cast it to a whole number. (values are in format like this 0.0, 1.0, 2.0) It's never 1.5 so it should be possible to turn it into whole numbers.
With this select i can grab the value i need but i don't know how i can turn the results from this into a whole number?
select coalesce(cast(tb.config_exit as json)->> 'exit_time_tenant' , '') as exit_time from table tb
When i try to say cast('1.0' as Integer) i get this ERROR: invalid input syntax for integer: "1.0"
This works but it's probably not a good solution?
cast(substring('1.0' from '([0-9]+)(.{1})') as Integer)