Become a Premium Member and unlock a new, free course in leading technologies each month.
Go Premium for a chance to win a PS4. Enter to Win
DECLARE @daysback INT = 5
WHILE(DATEPART(DW, GETDATE() - @daysback) IN (1,7))
SET @daysback = @daysback + 1
SELECT CONVERT(DATE,GETDATE() - @daysback, 101)
Open in new window
declare @dateStart datetime
, @dateEnd datetime
, @counter int
-- chop off time, initialize variable
select @dateStart = convert(varchar,current_timestamp,101)
, @dateEnd = convert(varchar,current_timestamp,101)
, @counter = 1
-- go back 5 days
While @counter <= 5 begin
select @dateStart = dateadd(dd,-1,@dateStart)
, @counter = @counter + case when datepart(weekday,@dateStart) in (1,7) then 0 else 1 end
-- show results
Author Closing Comment
Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.
Join & Ask a Question
Join our community for more solutions or to ask questions.
For immediate help use Live now!