Here are some useful T-SQL code snippets that you can uses for manipulating date.
--calculates the first day of the monthselect DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)--calculates the first day of the yearselect DATEADD(yy, DATEDIFF(yy,0,getdate()), 0)--calculates the first day of the quaterselect DATEADD(qq, DATEDIFF(qq,0,getdate()), 0)--calculates the first monday of the monthselect DATEADD(wk, DATEDIFF(wk,0,dateadd(dd,6-datepart(day,getdate()),getdate())), 0)--calculates the last day of the prior monthselect dateadd(ms,-3,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0))--calculates the last day of the prior yearselect dateadd(ms,-3,DATEADD(yy, DATEDIFF(yy,0,getdate()), 0))--calculates the last day of the current yearselect dateadd(ms,-3,DATEADD(mm, DATEDIFF(m,0,getdate() )+1, 0))--calculates the monday of the current weekselect DATEADD(wk, DATEDIFF(wk,0,getdate()), 0)--calculates the yesterdays dateselect DATEADD(dd, DATEDIFF(dd,0,getdate()), -1)
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.