How to extract dates (years) from a datetime variable