Just putting the @Rovann response in context
The DATEADD returns a date. O MONTH returns an integer representing the date month.
Soon your cloistered Where MONTH(TarVencimento) = DATEADD(MONTH,1,TarData) doesn’t seem to make sense.
It makes more sense, you cloister where, changing her to MONTH(TarVencimento) = MONTH(DATEADD(MONTH,1,TarData)). Where you add 1 month to the field TarData, takes the month and last compares with the month of TarVencimento.
Seeing your question, I see that I stopped in time with the studies of SQL Server, because I still use the DATEPART to pick up the month in the date fields, getting something like: DATEPART(MONTH, TarVencimento) = DATEPART(MONTH, DATEADD(MONTH,1,TarData)), which is still right too, because the DATEPART returns an integer representing the datepart of the specified date.
It is strange this consultation, explain better Tarid example Tarid = 173151 with several salaries?
– arllondias
Renan ?
– Rovann Linhalis
@Rovannlinhalis, you solved
– Renan Bessa