How to convert date into year and month and while analyzing a time series problem in R?

Hi All,

How do we implement Year to date and Month to date metrics while analyzing a time series problem in R?

Insights much appreciated.

Regards,
Tony