September 9, 2009 at 11:53 pm
hi all,
I have one table called "rates" with the following format.
start dateend date value
5/26/20016/29/2001 5.5
6/30/20017/27/2001 2
7/28/20018/24/2001 1
I need to write a query such that if i am entering any date value it should return the value corresponds to the date range.
FOr ex: If i gave the input as 7/01/2001 it should return the value as "2".
If i gave the input as [font="Arial"]04/01/2001[/font] then there are no corresponding value in the table. But for this the next higher date range value 5.5( 5/26/20016/29/2001 5.5) should return.
Please write me a query for this and let me know if u need more details.
Thanks in advance.
September 10, 2009 at 12:12 am
Couple of things first.
One, read the first article I reference in my signature block about asking for assistance. Please following the instructions in that article on what and how you should post such requests for assistance as this. This will provide you with an additional benefit, tested code.
Two, show us what you have tried trying to solve your problem. We may be able to help you with your logic instead of just writing the code you need.
September 10, 2009 at 2:08 am
Select top 1 * from rates where end_date >= Inputdate order by end_date
September 10, 2009 at 12:29 pm
Dave Ballantyne (9/10/2009)
Select top 1 * from rates where end_date >= Inputdate order by end_date
Based on the sample data, I'd drop the = from the >= in the where clause.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply