Search code examples
postgresqlintegersubstring

Get substring form an integer column


I had a quick question, how can I go about using SUBSTRING on an integer? I currently have field labeled "StoreID" that contains a 5 digit integer (60008). I am trying to use SUBSTRING to remove the 6 when I query out this information. When I use something like:

SUBSTRING('StoreID', 2, 6) I get an error returning back saying that SUBSTRING(integer,integer,integer) does not exist.

Is there another function I can use in postgres to accomplish what I am trying to do?


Solution

  • You can cast the integer

    SUBSTR(cast (StoreId as text), 2,6)