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 2005 Forums
 Transact-SQL (2005)
 Filter Date Between Two Dates

Author  Topic 

ravininave
Posting Yak Master

111 Posts

Posted - 2010-09-28 : 14:04:55
Hi all,
I've two fields in my Table like StartDate and EndDate. Actually Member will get paid from StartDate to EndDate. Now I've to query any Date and filter those entries which comes between these two days
Suppose StartDate is '01/01/2010' and EndDate is '20/02/2010' and I've to find if he is eligible to get paid on '15/01/2010' means I've to filter all those records which meets the criteria of my Date.
Can anyone suggest me the sql for this problem.


VB6/ASP.NET
------------------------
http://www.nehasoftec.com

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-09-28 : 15:20:43
It would be nice to give us the table structure so we can know for example what is the datatype of your column.
Then also you can give some example data and the wanted output in relation to the example data.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

ravininave
Posting Yak Master

111 Posts

Posted - 2010-09-28 : 15:38:55
Thanx for reply
SrNo. StartDate EndDate
1 01/01/2010 10/01/2010
2 08/01/2010 20/01/2010


If I search for Date 05/01/2010 then Result
SrNo
1

If I search for Date 09/01/2010 then Result
SrNo
1
2




Go to Top of Page

jleitao
Posting Yak Master

100 Posts

Posted - 2010-09-29 : 04:20:15
Hi ravininave,

SELECT
*
FROM
<TABLE>
WHERE '05/01/2010' BETWEEN STARTDATE AND ENDDATE

Go to Top of Page

ravininave
Posting Yak Master

111 Posts

Posted - 2010-09-29 : 15:04:26
Thanx it works.
Go to Top of Page
   

- Advertisement -