Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
kishoremcp
Starting Member
41 Posts |
Posted - 2013-10-18 : 03:43:24
|
hi,I have a column where dates are available.Ex: where the date starts from 2010-02-26 09:53:45.397 and ends at 2013-09-30 04:00:02.907. I want to have data for 26 weeks only. How do i get it. The date column name is Period and another column is Metrics. Is there is a possibility? If so how?Thanks in advance....RegardsKishore |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-18 : 08:14:49
|
26 weeks from when? from today backwards? or from latest date backwards?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
kishoremcp
Starting Member
41 Posts |
Posted - 2013-10-18 : 09:12:04
|
I need it from today to backwards..quote: Originally posted by visakh16 26 weeks from when? from today backwards? or from latest date backwards?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
RegardsKishore |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-18 : 09:27:36
|
[code]select ...from ...where [date] >= DATEADD(wk,DATEDIFF(wk,0,GETDATE())-26,0)AND [date] < DATEADD(dd,DATEDIFF(dd,0,GETDATE()),1)[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
kishoremcp
Starting Member
41 Posts |
|
|
|
|