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 2000 Forums
 Transact-SQL (2000)
 DateTime Handling

Author  Topic 

jia9211
Starting Member

7 Posts

Posted - 2004-06-19 : 03:21:55
I have a table ResourceAssignments in SqlServer 2000 with following data.

ResName..........FromDate.........ToDate
John 6/4/2004 6/12/2004
John 6/17/2004 6/22/2004
Peter 6/20/2004 6/27/2004

I want a stored procedure which gives me all the resources who are free from 6/12/2004 to 6/18/2004.
Thanks

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2004-06-19 : 04:29:23
create procedure prc_FreeResources
@StartDate DateTime,
@ToDate DateTime

as

select ResName, FromDate, ToDate from ResourceAssignments
where FromDate <= @StartDate and ToDate >= @ToDate
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-06-19 : 05:01:49
Please don't double post. It's not considered proper etiquette. :)

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

jia9211
Starting Member

7 Posts

Posted - 2004-06-19 : 05:01:52
brother this doesnt work,as for example if i want to check that who is available from 6/13/2004 to 6/16/2004, your query will return only Peter, but as you can see it should also return John as he is not assigned to any task in these days.
Go to Top of Page

jia9211
Starting Member

7 Posts

Posted - 2004-06-19 : 11:12:03
Thx for providing this help query, my problem is solved now, actually am new to TSQL and wasnt aware of Left Join like things.
Thanks again
Go to Top of Page
   

- Advertisement -