You can use the following:
select dateadd (dd, -datepart (dw, getdate ()), getdate ())
In this case, you get the time part as well, since getdate() includes the time. If you are using a column that is a datetime with no time component, then you also get the date with no time component, i.e.:
select dateadd (dd, -datepart (dw, Col1), Col1)
from MyTable
--
Tom
---------------------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCT
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
www.apress.com
Hello,
how can I calculate the date of the first day of the week in SQL ?
I know the week number in a year, and a year.
Regards
Jakub
--
_____________________________________________
Jakub Jablonski
Junior System Engineer
Ericpol Telecom sp. z o.o.
Targowa 9A, 90-042 Lodz, Poland
mobile:
tel: +48 42 6315520
fax: +48 42 6315555
http://www.ericpol.pl/
_____________________________________________