get last 4 digits of an integer
Posted in 2008
Topics: General Discussion
Hey guys, I'm having trouble figuring out how to select only the last 4 digits of an integer column. I'm sure that I've done it before, but I can't remember how. Any help would be greatly appreciated.
Sorry for the false alarm guys, I figured it out.
MATTHEW ELDERS schrieb: > Hey guys, > > I'm having trouble figuring out how to select only the last 4 digits of an > integer column. I'm sure that I've done it before, but I can't remember how. > Any help would be greatly appreciated. > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > Hi Matthew, the modulo function is your friend. Example: SELECT MOD(integercolumn, 10000) FROM sometable; Where MOD(integercolumn, 10) gives the rightmost digit MOD(integercolumn, 100) gives the 2 rightmost digits and so on. HTH dic_k -- Richard Kofler SOLID STATE EDV Dienstleistungen GmbH Vienna/Austria/Europe
That is perfect. Thank you so much. The way I found to do it was cluegy and hackish. Have a good one.