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 2008 Forums
 Transact-SQL (2008)
 Get date between date range.

Author  Topic 

keyursoni85
Posting Yak Master

233 Posts

Posted - 2012-05-22 : 07:53:06
I have exchange rate table in which there are multiple date wise records with exchange rate.

Date Rate
17/05/2012 5
23/05/2012 6
27/05/2012 7


Now I want rate while passing any date like if, I pass 20/05/2012 then rate 5 should return because 20/05/2012 elapse in date range 17 and 23 may 2012.

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-05-22 : 08:42:03
SELECT TOP 1 rate
FROM yourTable
WHERE @yourParameter >= [Date]
ORDER BY [date] desc

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

keyursoni85
Posting Yak Master

233 Posts

Posted - 2012-05-23 : 02:55:59
thanks.
Go to Top of Page
   

- Advertisement -