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
 SQL Server Development (2000)
 Selecting the correct date range

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-05-23 : 00:49:11
Matt writes "I am working on a database which stores letting information about properties including the prices which differ during different times of the year. Therefore 1 property can have several seasons which I identify using two datetime fields called rather unimaginitively 'dtFrom' and 'dtTo'. I would like to bring back the correct row based on a date input by the user without any of the other rows.

e.g. A property has the following seasons;

dtFrom          dtTo          Price
01/05/2001 01/10/2001 100
01/11/2001 01/20/2001 200
01/21/2001 01/30/2001 300


If I enter the date 01/15/2001 how do I get it to return only row 2!

There's probably a really easy way to do this but I'm pretty new to SQL so I'm struggling and by boss is getting impatient. Please help.

I'm using SQL Server 7.0 with Windows 2000 professional."
   

- Advertisement -