sql - Query to get all the data prior to 2 weeks -


can please me query retrieve defect data creation date prior 2 weeks. know below query can me data.

select defect_id, assigned_to, created_date  bug created_date < dateadd(week,-2,getdate()); 

but tricky part here when 2 weeks prior mean is, today monday 25th jan , need data 2 weeks prior today, need data prior 18th jan. mean here present week has data 25th jan , previous week has data 18th jan 24th jan. when 2 weeks prior dont mean 14 days data days excluding present week , previous week.

so need query work day of week , give me data excluding present week , previous week. week endind sunday.

you can subtract day of week , subtract 1 week:

select defect_id, assigned_to, created_date  bug created_date < dateadd(day, - (7 + day(getdate())), getdate()) ; 

this may not want, should put on right path.


Comments