Results 1 to 4 of 4
  1. #1
    pullaiah.cts is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    2

    Purging 7 yrs old data from Access

    Hi all,



    This is my first post in this forum.

    I have requirement that I need to purge the records from all the tables that are older than 7 years.I have identified the fileds based on which I can delete the data but the problem is how to write the query to fetch the data that is older than 7 Years.

    This is my query:
    Select * from Case where StatusDate < DateValue('01/01/2005')

    But I want to get the date based on current date.For example,If I want to delete the data that is exactly older than 7 years from current date i.e. data older than sep 27th,2005.

    Is there any way to get the data that is exactly older than 7 years.

    Thanks in advance.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Check out the DateAdd() function (and the Date() function):

    Select * from Case where StatusDate < DateAdd(...)

    with the appropriate arguments inserted.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    pullaiah.cts is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    2

    Purging 7 yrs old data from Access

    Hi Paul,

    I have tried the query with DateAdd function and it perfectly suits my requirement.

    select count(*) from Case where OpenedDate <= DateAdd ('yyyy', -7, now())

    Thank you so much for your help!!!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help. Welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Fetch Data From MS-Access
    By kashif.special2005 in forum Programming
    Replies: 1
    Last Post: 08-27-2011, 05:50 AM
  2. Access Data Repeats
    By coreytba3 in forum Access
    Replies: 1
    Last Post: 08-04-2011, 01:00 PM
  3. EDI data into Access database
    By cazper67 in forum Access
    Replies: 2
    Last Post: 07-24-2010, 05:57 PM
  4. Access Programming and Access Data Page
    By frmdread67 in forum Programming
    Replies: 0
    Last Post: 03-19-2008, 03:11 PM
  5. Report SQL/Data in Access
    By artfuldodger in forum Access
    Replies: 2
    Last Post: 09-01-2006, 07:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums