Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select between date OR null

Status
Not open for further replies.

chaoma

Technical User
Apr 17, 2005
101
US
Hello,

Could someone please help me with this problem. Any help would be appreciate.

I have a table like below:

pid date start_dt end_dt
1 20050401 20030825 20050417
1 20050401 20050418 Null
2 20050411 20050106 Null
3 20050402 20050106 20050401

All NULL end_dt mean indefinite into the future.

I want all the row with DATE that fall within the start and end date as:

pid date start_dt end_dt
1 20050401 20030825 20050417
2 20050411 20050106 Null

I have try the following, but it return the top 3 rows:

Select *
From mytable
Where
Date BETWEEN start_dt AND end_dt
OR end_dt is null


Again, thank you for your help.
 
Where Date >= start_dt AND (Date <= end_dt OR end_dt is null)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks.

It so simples. I don't know why I could not figure that out.

Again, thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top