SOF User
SOF User

Reputation: 7830

Date Range SQL Query

Schedule_ID---Card No----FromDate----ToDate

4-------------1000058----01-Aug-10---31-Aug-10
5-------------1000058----01-Sep-10---30-Sep-10
6-------------1000058----06-Oct-10---26-Oct-10
7-------------1000099----06-Oct-10---26-Oct-10

What will be the query so i can find that is 08-Oct-10 Exist for 1000058 in table

SELECT Schedule_ID 
FROM TBL_SCHEDULE 
WEHRE CARD_NO = 1000058 AND .......... (WHAT MORE)

Like this query must result Schedule_ID = 6 because this date 08-Oct-10 is in range of Schedule_ID = 6.

Upvotes: 1

Views: 1108

Answers (1)

Will A
Will A

Reputation: 24988

SELECT Schedule_ID 
FROM TBL_SCHEDULE 
WHERE CARD_NO = 1000058 
  AND yourDate BETWEEN FromDate AND ToDate

Upvotes: 6

Related Questions