Last post Jul 13, 2015 05:20 PM by Rion Williams
Jul 13, 2015 05:00 PM|Lio1972|LINK
Hi I am trying to specify time in Sunday of the current week
So far I got this but adding the minutes doesn't work
select DateAdd(day, 7-datepart(weekday,Convert(date,getdate())),Convert(date,getDate())) + "" + '00:00:00'
Jul 13, 2015 05:15 PM|limno|LINK
Use Datetime instead of Date date type:
select DateAdd(day, 7-datepart(weekday,Convert(datetime,getdate())),Convert(datetime,getDate()))
Jul 13, 2015 05:20 PM|Rion Williams|LINK
So you want to essentially grab a timestamp for Sunday of the current week (at midnight)?
SELECT CONVERT(VARCHAR(10),DATEADD(DAY , 7 - DATEPART(WEEKDAY,GETDATE()),GETDATE()),120) + ' 00:00'
So if you were to execute this today, it would yield "2015-07-18 00:00". You can
see a specific example here.