Results 1 to 3 of 3

Thread: How to compare Date field in MS ACCESS that more than 2year compare to sysdate in sql

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    445

    How to compare Date field in MS ACCESS that more than 2year compare to sysdate in sql

    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
    Last edited by wenight; Sep 21st, 2007 at 11:42 PM.

  2. #2
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: How to compare Date field in MS ACCESS that more than 2year compare to sysdate in sql

    You can do that as below: The first query is faster.

    1. Filter befor grouping:
    Code:
    SELECT ACName, year(InDate) AS InYear
    FROM ACInfo 
    WHERE (year(InDate)<= year(Date)-2)
    GROUP BY ACName, year(InDate)
    2. Grouping before filter:
    Code:
    SELECT ACName, year(InDate) AS InYear
    FROM ACInfo 
    GROUP BY ACName, year(InDate)
    HAVING (year(InDate)<= year(Date)-2)

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    445

    Re: How to compare Date field in MS ACCESS that more than 2year compare to sysdate in sql

    Yeah~~ Thanks you very much!! It's work now!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width