We can use Year() and Month() functions to return Year and Month values from the Date.
Ex:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |