SUBSTRING in a number
Hi .
I am useing substring with a field number and this not ok.
I wold like use a function for a field number.
My field is f1=130001
I want get f1=13
Is possible?
0
Hi .
I am useing substring with a field number and this not ok.
I wold like use a function for a field number.
My field is f1=130001
I want get f1=13
Is possible?
Comments
hi,
If you know that you always need first 2 characters out of your string "f1" then you can use left function.
dbadmin=> select left('130001',2);
left
13
(1 row)
Regards,
Raghav Agrawal
thanks ,but is problen field es number .
Good day
Yes, you are correct. i had to cast the datatype into char type.
OR
Regards
Perfect ,thanks so much
But: do you need the result as numeric, or as string?
If you remain numeric, you should not perform string operations on numbers.
If I need to get 13 out of 130001, I would go
130001 // 10000
- that's an integer division by 10000.I need numeric because this field the use in other tables later and are a lot of tables.
Thanks.