This is an easy one, but some people don’t know it: if you need the last two digits of a year, say 2007, it’s very easy to get, without converting to a string and getting the last two characters:
Now that you know, it’s obvious, right?
And if you want the last three digits? number % 1000. In general:
What about first N digits? similarly easy: