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)
 How to get a row between two dates

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-10-13 : 08:03:34
Krishna writes "i want to pick a row which fall between two dates

like :


hotelCode -roomcode -StayStartdate -StayEndDate --- Price
1001 101 01-Oct-2005 30 Nov 2005 100 Rs
1001 101 01-Dec-2005 31 Dec 2005 200 Rs
1002 103 01-Oct-2005 30 Nov 2005 150 Rs
1003 104 03 Dec 2005 31 Dec 2005 200 Rs

suppose any one want to stay 30 Nov to 2 Dec
for this i want only first two records because rest of not fall in this category.

Because 1002 stayEndDate is 30 Nov
and i003 has staystartdate is 3 dec

Please suggest

Thanks"

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2005-10-13 : 08:11:12
Hi
You can use between clause .. try searching for the between on book online .. you will be better samples which suits what you want.

Complicated things can be done by simple thinking
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-13 : 08:55:49
Is this?

Select Columns from yourTable where StayStartdate <='30-Nov-2005' Or StayEndDate <='31 Dec 2005'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -