How to compare Date field in MS ACCESS that more than 2year compare to sysdate in sql
this is my simple logic... but not work....
Code:SELECT ACName,year(InDate)
FROM ACInfo
HAVING (year(date()) - Max(year(InDate))>=2)
GROUP BY ACName
Printable View
How to compare Date field in MS ACCESS that more than 2year compare to sysdate in sql
this is my simple logic... but not work....
Code:SELECT ACName,year(InDate)
FROM ACInfo
HAVING (year(date()) - Max(year(InDate))>=2)
GROUP BY ACName
You can do that as below: The first query is faster.
1. Filter befor grouping:
2. Grouping before filter:Code:SELECT ACName, year(InDate) AS InYear
FROM ACInfo
WHERE (year(InDate)<= year(Date)-2)
GROUP BY ACName, year(InDate)
Code:SELECT ACName, year(InDate) AS InYear
FROM ACInfo
GROUP BY ACName, year(InDate)
HAVING (year(InDate)<= year(Date)-2)
Yeah~~ Thanks you very much!! It's work now!!