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

Help with Having

Status
Not open for further replies.

Jackxxx

Programmer
Jun 21, 2007
31
US
In my HAVING here I'm trying to only return a row if the max paymentdate is older than 12 months back from today. I don't seem to be able to get it.

If the max paymentdate is 3/14/2010 it should not return a row. But if it was 3/14/2009 is should return a row.

HAVING (MAX(tblPayments.PaymentDate) NOT BETWEEN GETDATE() AND DateAdd(m,-12,GETDATE()))
 
Try reversing your dates so that it says:
Code:
Between DateAdd(m, -12, GetDate()) and GetDate()
 
With between it is not as important but when working with dates keep in mind that it may include the time.

djj
The Lord is My Shepard (Psalm 23) - I need someone to lead me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top