Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Oct 2002
    Location
    New Salem, North Dakota, USA
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    5 year increments (2000)

    I have a date field - Hire_Date - mmddyyyy
    I need to take todays date and compare it to the Hire_Date and if the difference is a 5 year increment I would like to see these records. We would like it to just look at the month and year.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: 5 year increments (2000)

    You can put the following function into a VBA module:

    Function Age(Date1, Date2) As Integer
    ' Returns the Age in years between 2 dates
    Age = Year(Date2) - Year(Date1)
    If Month(Date2) < Month(Date1) Then
    Age = Age - 1
    End If
    End Function

    This version of the Age function only looks at month and year, it ignores the day of the month. Use it in your query as follows:

    <code>Increment: Age([hire_Date], Date())</code>

    and set the criteria for this column to 5 or >=5 or whatever you need.

Posting Permissions

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