Date Query

W

www.ttdown.com

I have a database that I need to query. The database contains a
ClientName field and DateofService (MM/DD/YYYY) field. I need to
query the database and return only the Client Names that have some
entries in the DateofService field but don't have a DateofService in
the last 90 days. Can anyone help?

Thanks!
 
J

John Vinson

I have a database that I need to query. The database contains a
ClientName field and DateofService (MM/DD/YYYY) field. I need to
query the database and return only the Client Names that have some
entries in the DateofService field but don't have a DateofService in
the last 90 days. Can anyone help?

The format of the DateOfService is irrelevant - that merely controls
how the value is displayed.

You need the rather obscure NOT EXISTS clause in your query:

SELECT * FROM yourtable
WHERE Not Exists(SELECT ClientID FROM yourtable
WHERE DateOfService > DateAdd("d", -90, Date()))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top