SQL Statement for Expired Records

I have a field EXPIRATION_DATE in table DOMAIN. This field can be null. I would like to select records in this table based on EXPIRATION_DATE field so that the SQL query return the records where EXPIRATION_DATE is null and for the records where expiration date is not null it only returns the record when GetDate() < EXPIRATION_DATE. Please help me in writing this query.

Thanks,
Nauman.
LVL 25
nauman_ahmedAsked:
Who is Participating?
 
LowfatspreadCommented:
select * from domain
where expiration_date is null
or expiration_ date > getdate()
0
 
Patrick MatthewsCommented:
Hi nauman,

SELECT *
FROM DOMAIN
WHERE (EXPIRATION_DATE IS NULL) OR (EXPIRATION_DATE > GETDATE())

Regards,

Patrick
0
 
nauman_ahmedAuthor Commented:
I totally missed the OR clause. Thanks for the quick reply experts :)

-Nauman.
0
 
Patrick MatthewsCommented:
Glad to help :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.