stephenlecomptejr
asked on
Need help changing a Microsoft Access select query having to show only dated records more than 7 days old.
Need help with changing Microsoft Access SQL query to show date entered records that are more than 7 days old.
So far a lot of suggestions have not really worked for me at this link so I decided to add this as a new question:
https://www.experts-exchange.com/questions/29140112/Need-help-with-creating-a-cross-tab-report-that-would-identify-the-last-date-an-employee-entered-time.html?headerLink=workspace_answered_questions
I know must include : HAVING but no data is coming up with records that do have dates more than 7 days old.
When I try the above I get DataType mismatch in criteria expression.
If I try below- I get no errors but I also get no records which can't be right cause 80% are over 7 days old
So far a lot of suggestions have not really worked for me at this link so I decided to add this as a new question:
https://www.experts-exchange.com/questions/29140112/Need-help-with-creating-a-cross-tab-report-that-would-identify-the-last-date-an-employee-entered-time.html?headerLink=workspace_answered_questions
I know must include : HAVING but no data is coming up with records that do have dates more than 7 days old.
SELECT Employees.EmployeeID, Employees.UserName, Max(TimeSheetData.DateEntered) AS MaxOfDateEntered
FROM Employees LEFT JOIN TimeSheetData ON Employees.EmployeeID = TimeSheetData.EmployeeID
GROUP BY Employees.EmployeeID, Employees.UserName
HAVING DateValue(Max(TimeSheetData.DateEntered)) > DateAdd("d",7,Date())
ORDER BY Max(TimeSheetData.DateEntered) DESC;
When I try the above I get DataType mismatch in criteria expression.
If I try below- I get no errors but I also get no records which can't be right cause 80% are over 7 days old
SELECT Employees.EmployeeID, Employees.UserName, Max(TimeSheetData.DateEntered) AS MaxOfDateEntered
FROM Employees LEFT JOIN TimeSheetData ON Employees.EmployeeID = TimeSheetData.EmployeeID
GROUP BY Employees.EmployeeID, Employees.UserName
HAVING Max(TimeSheetData.DateEntered)>DateAdd("d",7,Now())
ORDER BY Max(TimeSheetData.DateEntered) DESC;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dale's was the one that worked correctly. Appreciate all the replies.
Open in new window