Home SQL Server Last week from sun to sat
Reply: 0

SQL Server Last week from sun to sat

user4739
1#
user4739 Published in September 19, 2018, 11:14 am

I am trying to get date from Sun to sat of last week my code is,

Declare
      @now DateTime, @fmWeek DateTime, @toWeek DateTime

Set @now = GetDate()
Set @fmWeek = Convert(DateTime, DateAdd(wk, DateDiff(wk, 0, @now), -1))
Set @toWeek = DATEADD(ms,-3,Convert(DateTime, DateAdd(wk, DateDiff(wk, 0,  @now), 6)))

select @fmWeek, @toWeek

It shows me data from 2018-04-15 00:00:00.000 to 2018-04-21 23:59:59.997

I need to get dates from previous week sun to sat not the same week

share|improve this question

2 Answers 2

active oldest votes
up vote 2 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.5147 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO