Question:
I want to display the current month and year in a SQL query, I want it to look like this:
april/2020
I tried this:
SELECT DATENAME(MONTH,GETDATE()) + ' / ' + YEAR(GETDATE())
But, I get the following error:
Error de conversión al convertir el valor nvarchar 'Abril / ' al tipo de datos int.
How do I solve it?
Answer:
It is because YEAR returns integer. You can use the same DATENAME function for the year.
SELECT DATENAME(MONTH,GETDATE()) + ' / ' + DATENAME(YEAR,GETDATE())