'10/10/2018' is the given date, I want to find week start date in which this date falls..according to calendar
Asked
Active
Viewed 94 times
-1
-
1Start of the week depends on the culture. also is this field a date derivative, also you tagged C# what role does C# play in this, also you have shown no code, no research, and no problem as such – TheGeneral Mar 05 '19 at 04:41
-
i just want to find start date of a week – D.Jones Mar 05 '19 at 04:43
-
it gives wrong date for 11/11/2018 @Alex – D.Jones Mar 05 '19 at 05:17
3 Answers
0
You can get the first day of the week like following.
declare @inputdate date='10/10/2018'
select DATEADD(dd, -(DATEPART(dw, @inputdate)-1), @inputdate) [WeekStart]
If you want to change the first day of week to a specific day, for this you can use SET DATEFIRST
SET DATEFIRST 7
declare @inputdate date='10/10/2018'
select DATEADD(dd, -(DATEPART(dw, @inputdate)-1), @inputdate) [WeekStart]

PSK
- 17,547
- 5
- 32
- 43
0
You can try below -
select DATEADD(dd, -(DATEPART(dw, '10/10/2018)-1), '10/10/2018)

Fahmi
- 37,315
- 5
- 22
- 31
0
Please try this query:
SELECT DATEADD(DAY, 2 - DATEPART(WEEKDAY, '10/10/2018' ), CAST('10/10/2018' AS DATE)) [Week_Start_Date]

Eriawan Kusumawardhono
- 4,796
- 4
- 46
- 49

Hemang A
- 1,012
- 1
- 5
- 16