From: Muhammad Bilal on
Hi.

I want to to know the date of the day Monday of the current weak.
Suppose if today is 31 Jan 2010. It return the date of Monday as 25 Jan 2010.



Regards,
Muhammad Bilal
From: Plamen Ratchev on
You can use the following formula based on offset from well known Monday date:

DECLARE @dt DATETIME;

SET @dt = '20100131'; -- 31 Jan 2010

-- Jan 1 2009 is Monday
SELECT DATEADD(DAY, (DATEDIFF(DAY, '19000101', @dt) / 7) * 7, '19000101') AS monday_date;

/*

monday_date
-----------------------
2010-01-25 00:00:00.000

*/

--
Plamen Ratchev
http://www.SQLStudio.com
From: Uri Dimant on
Muhammad
Anothe method is
SELECT '20100131' -

datepart(weekday, CAST('20100131'AS DATETIME) + @@datefirst - 1) + 1 as

Mon

See @@datefirst vairable may not be the same for all regions









"Muhammad Bilal" <MuhammadBilal(a)discussions.microsoft.com> wrote in message
news:91C3680E-3331-49D3-8CAF-9E0B2A032D66(a)microsoft.com...
> Hi.
>
> I want to to know the date of the day Monday of the current weak.
> Suppose if today is 31 Jan 2010. It return the date of Monday as 25 Jan
> 2010.
>
>
>
> Regards,
> Muhammad Bilal