Hi @saad_el_eulj,
Welcome to the RStudio Community Forum.
Here is a simple way to extract the year from a date, and deliver the result as a number, using the year() function from the {lubridate} package:
library(lubridate)
#>
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#>
#> date, intersect, setdiff, union
year(as.Date("2015-05-17"))
#> [1] 2015
Created on 2021-05-25 by the reprex package (v2.0.0)