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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date field as a criteria, please help

Status
Not open for further replies.

croiva25

Technical User
Dec 3, 2003
125
0
0
AU
HOw do I write correctly a query where I want to say give me everything where Created is before 1/6/2004 and InvoiceReceived are not after 1/6/2004.



So some of these results can be created before 1/6/2004 but we are still using them and invoicing is coming through, but I want to find what was created before that date and Invoicing is not coming through any more, therefore we are not using their services.



Thanks to whoever helps me.
 
SELECT *
FROM MyTable
WHERE Created < '2004-01-06'
AND InvoiceReceived < '2004-01-06'

Thanks

J. Kusch
 
I don't know if I have gone damb, but I have tried that and similar queries but that gives me results where Invoices were received up until that date, when what I need is a list of results where no inovoices, no activaity was done after this date.

 
I was thinking something like
select * from test where Created < '20053105' and NOT InvoiceReceived >'20053105' do you see my logic, but this is not correct, I don't think this option exists

 
I think you might have to give us an example of your data and what you want returned?

--James
 
Maybe something like this......

Code:
SELECT *
FROM   MyTable
WHERE 
  --Created is before 1/6/2004 
  Created < '2004-01-06' 
AND 
  --InvoiceReceived are not after 1/6/2004.
  --where no invoices, no activity was done after this date.
  (InvoiceReceived > '2004-01-06'
   AND InvoiceReceived IS NULL)

But as James said, it really would help if you would provide some sample data and what you would expect to see returned.

-SQLBill


Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top