| Author |
Topic |
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2008-03-06 : 06:24:39
|
| hi,how can I get the first day of the week 12 weeks ago ? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-03-06 : 06:31:42
|
| DATEADD(d,(-1) * DATEPART(dw,GETDATE()),DATEADD(wk,-12,GETDATE()))also remember to SET DATEFIRST to your first day of the week. |
 |
|
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2008-03-06 : 07:50:50
|
| set datefirst ? |
 |
|
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2008-03-06 : 07:55:21
|
| also , this seems to go back 15 weeks !? very strange |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-03-06 : 07:59:48
|
| 15 weeks? how? |
 |
|
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2008-03-06 : 08:10:00
|
| not sure, but it shows the 08 dec 07.. |
 |
|
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2008-03-06 : 08:19:27
|
This is the 10th week of 2008, so 12 weeks ago is in Dec 2007 Poor planning on your part does not constitute an emergency on my part. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-03-06 : 08:19:33
|
Thats almost correct. Counting backwards you will get thursdays as28Feb2008 121Feb2008 214Feb2008 307Feb2008 431Jan2008 524Jan2008 617Jan2008 710Jan2008 803Jan2008 927Dec2007 1020Dec2007 1113Dec2007 12now you have to find out starting day (Sunday) of week having 13Dec2007 which is 9 Dec...so probably you need add 1 to earlier result. i.eDATEADD(d,(-1) * (DATEPART(dw,GETDATE())-1),DATEADD(wk,-12,GETDATE())) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-03-06 : 08:21:59
|
quote: Originally posted by dataguru1971 This is the 10th week of 2008, so 12 weeks ago is in Dec 2008 Poor planning on your part does not constitute an emergency on my part.
Did you meant Dec 2007? |
 |
|
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2008-03-06 : 08:47:26
|
quote: Originally posted by visakh16
quote: Originally posted by dataguru1971 This is the 10th week of 2008, so 12 weeks ago is in Dec 2008 Poor planning on your part does not constitute an emergency on my part.
Did you meant Dec 2007?
LOL..absolutely did mean 2007....or it was my attempt to be as confused as everyone else around here. Poor planning on your part does not constitute an emergency on my part. |
 |
|
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2008-03-06 : 08:53:15
|
| ok, thank you very much ! |
 |
|
|
|