Came across this issue in our scripts since the New year.
We have several scripts which look back 1 month from current UTC date. Since the New Year, these scripts return zero results because, I assume, Sql doesn't see month 12 as being minus 1 from month 1.
Is there a way to force sql to see the year as the rotating data it is rather than an incremental line?
**Edit
Apologies, I forgot to add examples.
So, one line reads
Select .... Where ...
And month (timevalue) = month (getutcdate ()) -1
This gives zero results despite working correctly until January.
I've changed it temporarily to be = 12 which does return the correct data.
**Edit 2
Yep, thanks for the link and sample code. Works perfectly so far. I guess with our current setup it's not using daytime as I assumed, but instead using the month value as an int?