BeardedSith
BeardedSith

Reputation: 129

BETWEEN SQL Statement tossing Overflow Error - pulling records between two dates

Ran into a problem with a query I created in Access. I'm getting an error that simply states "Overflow" and I'm not sure what's causing huge calculations here, so I could use a little advice. Here's the query:

SELECT tbPurchases.MemberID, Count(tbPurchases.[PurchaseDate]) AS NumPurchases
FROM tbPurchases
GROUP BY tbPurchases.MemberID
HAVING (((Count(tbPurchases.[PurchaseDate])) Between DateSerial(Now(),1,1) And Now()));

This was created using the GUI in Access. Basically, I'm attempting to grab the number of instances a MemberID shows up in tbPurchases (yeah, I left out an "L" - fix it later) that have PurchaseDate's between the first of the year and Now().

Upvotes: 0

Views: 37

Answers (1)

Gustav
Gustav

Reputation: 55806

You probably mean:

SELECT 
    tbPurchases.MemberID, 
    Count(*) AS NumPurchases
FROM 
    tbPurchases
WHERE 
    tbPurchases.[PurchaseDate] Between DateSerial(Year(Now()),1,1) And Now()
GROUP BY 
    tbPurchases.MemberID

Upvotes: 2

Related Questions