sql server - Get last 5 week range -
i need load info last 5 weeks in 5 seperate lists, no matter date. week, i'll need last 5 weeks before one. next week i'll need last 5 weeks before one, includes one. if makes sense , doesn't confuse you?
so basically:
..between '2015-09-21' , '2015-09-27'
has replaced with:
select dateadd(wk,datediff(wk,7,getdate()),0) , dateadd(wk,datediff(wk,7,getdate()),6)
this works fine, same second week:
select dateadd(wk,datediff(wk,14,getdate()),0) , dateadd(wk,datediff(wk,14,getdate()),6)
but on, doesn't work anymore. different results when add date manually.
select dateadd(wk,datediff(wk,21,getdate()),0) , dateadd(wk,datediff(wk,21,getdate()),6)
am doing wrong in code?
if use between
datetime
data type should add 7 days beginning of week find end of week
dateadd(wk,datediff(wk,21,getdate()),7)
Comments
Post a Comment