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
 General SQL Server Forums
 New to SQL Server Programming
 Query statement

Author  Topic 

dFresh
Starting Member

4 Posts

Posted - 2008-08-12 : 15:40:21
Lucky me, I've been assigned the task of creating some views in SQL for reporting. It's one of those extra duties that you get assigned just because you're in the office.

I work in a Project Management office, so I'm trying to make a 2 week due report. I already have the tables that I need, it's the coding that I'm having trouble with.

This is what I have so far:

WHERE (dbo.MSP_TmpTask.TaskFinishDate = dbo.MSP_TmpTask.TaskFinishDate - 14)

What I'm trying to displays are the tasks that have a finish date, of such n such, minus 14 days. I should see just the tasks that are due in 2 weeks.

When I run the query I get zero results. Any help would be appreciated.

Thanks

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-08-12 : 15:45:49
WHERE (dbo.MSP_TmpTask.TaskFinishDate >= DATEADD(d, DATEDIFF(d, 0, GetDate()), -14)


_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-12 : 16:43:32
That are due in two weeks?

SELECT *
FROM Table1
WHERE Col1 >= GETDATE() AND Col1 < DATEADD(DAY, 14, GETDATE()



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

dFresh
Starting Member

4 Posts

Posted - 2008-08-12 : 18:35:45
oops, slight change sorry. Instead of using TaskFinishDate. How can I use the current date? I tried using 'Datetime()' function but it says it doesn't recognize this function.
Go to Top of Page

singularity
Posting Yak Master

153 Posts

Posted - 2008-08-12 : 19:23:04
getdate() will get you the current date.
Go to Top of Page
   

- Advertisement -