You really can use year(3:4); however your string will still contain four characters, i.e. it will contain two numbers and two spaces. To illustrate this, here is an example:
program trunc
character(len=4) :: year = "2011"
write(*,'(A,A,A)') '..', year, '..'
year = year(3:4)
write(*,'(A,A,A)') '..', year, '..'
end program trunc
Will print
..2011..
..11 ..
To really get "11"instead "11 ", you need to assign a value to a variable that can only contain two characters.
source
share