0
votes

Table X has start_date and end_date and related information associated with these dates. BOTH stored in DB in date format. I need to find a specific date say 12th-Jan-2000 and extract the rows whose date range includes this date. Could someone please help me out. I am new to SQL so need some guidance here.

Table X:

ID |start_date|end_date
1  |12/30/1999|01/12/2000
2  |01/20/2000|01/30/2000
3  |01/07/2000|01/15/2000

Thus my query should give back the ID-3 since 12th January falls in the range 01/07/2000-01/15/2000

Thanks

1
Which are you using, MySQL or Oracle?Barmar
I am using sql developer.Ak1671LA

1 Answers

2
votes

use the BETWEEN operator:

SELECT *
FROM TableX
WHERE DATE'2000-01-12' BETWEEN start_date AND end_date