Get Month and Year value from the Date

We can use Year() and Month() functions to return Year and Month values from the Date. 
Ex:

Integer Year = Date.Today().Year();
System.debug('year::: '+year);
13:33:52:002 USER_DEBUG [3]|DEBUG|year::: 2020
Integer Month = Date.Today().Month();
System.debug('Month::: '+Month);
13:33:52:002 USER_DEBUG [4]|DEBUG|Month::: 12
view raw gistfile1.txt hosted with ❤ by GitHub