Just trying to troubleshoot an issue with one of my developers and came across this "feature" with DATEADD.
He had something akin to, SELECT DATEADD(Y,-1,DateColumn) and couldn't understand why it wasn't returning the correct data. It turns out that using the datapart Y in this context actually runs as if it were D.
I checked the documentation in BOL which states that YY or YYYY are valid dateparts for year which i accept. But it surprises me that Y doesn't work and worse than that, doesn't throw an error. If i use the datapart X i get an error "X'
is not a recognized dateadd option".
I'm using SQL 2008 SP1. Just thought i'd sound out the forums before raising this on Connect.every day is a school day
View Complete Post