Friday, January 20, 2012

First date of a week using SQL

How to get the first date / day in a week using SQL Server.?



The example gets the date of the first day in the week that GETDATE() is in.

SELECT DATEADD(ww, DATEDIFF(ww,0,GETDATE()), 0)

It's yery simple and quite elegant,  Happy Coding!! :)