I want to get all dates by declaring month and year in SQL server.
Can anyone please share easy lines of SQL code to get it.
For example:
WHERE Dates LIKE '2018-12%'
In a datetime or timestamp it goes Year-Month, so this would pull everything that matches 2018 in December. You can mod this to use your variables as well.
@month = 12; @year = 2018; @searchQuery = @year + @month + '%'; WHERE Dates LIKE @searchQuery