You use LEFT function.
SELECT LEFT(20010112, 4)
You should get 2001
This function works on string too.
|||this left function is for string. if you pass in a integer, the integer value is implicit convert to stringso 20010112 is converted to '20010112'.
You can convert the integer to string before using substring
substring(convert(varchar(10), @.intvar), 5, 2)
No comments:
Post a Comment