How can I make a query bring me results that, for example, the PaymentDate is equal to the same month of a variable
I explain
I have this query
Declare @FechaReporte DATETIME
SET @FechaReporte = ‘2022-05-31’
Select
NumCredito,
Nombre,
FechaPago
From Creditos
That query brings me a list of credits, what I want is for it to bring me only those that in the Payment Date, have been paid the same Month of the variable, since the variable is in May, all the credits that have been paid in May
I was trying to use Month but I have not succeeded
How have you been using the
MONTH()
? I have tested it and it works fine.The output should be: