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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Help with DatePart or Dataadd view script?

Author  Topic 

ostinoh
Yak Posting Veteran

66 Posts

Posted - 2012-01-31 : 13:01:19
Hello -

I'm tying to create a SQL View that will allow users to query the data in excel file.

I need help to write a script to pull this weeks data + 13 weeks ahead. I'm at a lost for the logic.

I can't even supply an example of what I have been trying because I know I'm not even close.

Can anyone shed some light on this for me?

Regards,
D-

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-31 : 13:18:38
use where condition like below

WHERE datefield >=DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
AND datefield <DATEADD(wk,DATEDIFF(wk,0,GETDATE())+14,0)


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

ostinoh
Yak Posting Veteran

66 Posts

Posted - 2012-01-31 : 14:39:36
Thank you that is what I was looking for.
Go to Top of Page
   

- Advertisement -