Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Location
    New York, New York, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date Arithmetic (Access 2007)

    I have a query that I use to select records that are older than 5 years. In the date column I have coded, <#10/09/2003#, but it's a pain to have to change that hard-coded value each time I run the query. I'm sure there is a way to automatically calculate the date 5 years earlier than today, but I can't figure out how.
    I'd appreciate any help.

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

    Re: Date Arithmetic (Access 2007)

    You can use the DateAdd and Date functions for this. Enter the following expression in the Criteria row:
    <code>
    <DateAdd("yyyy",-5,Date())
    </code>
    Date() returns the current date.
    DateAdd adds -5 years to this date, i.e. subtracts 5 years.

  3. #3
    Star Lounger
    Join Date
    Apr 2002
    Location
    New York, New York, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date Arithmetic (Access 2007)

    Once again, I want to thank you for your wonderful help. I am working with several databases I created 10 years ago, and, as you can see, I am very rusty, so I appreciate your help very much.
    Michael Trombetta

Posting Permissions

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